botocore.exceptions.SSLError: SSL validation failed

11,024

@azhwani, as you are not using AWS IoT Core, this does not seem to be an issue related to an expired certificate.

Run:

$ aws configure

... and insert your AWS credentials.

Share:
11,024
Azhwani
Author by

Azhwani

Updated on December 09, 2022

Comments

  • Azhwani
    Azhwani over 1 year

    Meta

    Python: 2.7.5
    Pip : pip 18.1 from /usr/lib/python2.7/site-packages/pip (python 2.7)
    AWS CLI : aws-cli/1.16.104 Python/2.7.5 Linux/3.10.0-862.3.3.el7.x86_64 botocore/1.12.94
    Boto3 : 1.9.94
    Centos : CentOS Linux release 7.5.1804 (Core)

    My script

    import boto3
    from botocore.exceptions import ClientError
    ec2 = boto3.client('ec2')
    try:
        response = ec2.describe_instances()
        print(response)
    except ClientError as e:
        print(e)
    

    When I run my script, I get this exception :

    • botocore.exceptions.SSLError: SSL validation failed for https://ec2.region.amazonaws.com/ hostname 'ec2.region.amazonaws.com' doesn't match either of '*.com.com', 'com.com'

    Please any help would be appreciated! Thanks!

    • razimbres
      razimbres over 5 years
      Did you run $ aws configure to insert your credentials ?
    • Azhwani
      Azhwani over 5 years
      Hello @Rubens_Z, yes I did I already generate the two files : ~/.aws/credentials and ~/.aws/config
    • razimbres
      razimbres over 5 years
      I had this issue with a AWS IoT Core certificate. Probably idle for some time. My solution was to generate another certificate.
    • Azhwani
      Azhwani over 5 years
      What do u mean by generate another certificate? Do I need to install an SSL certificate in my centos server ?
    • razimbres
      razimbres over 5 years
      Probably the certificate I used for AWS IoT Core expired. I am able to run your code in my machine and get the output for EC2, like ImageId, InstanceType, KeyName, etc The only certificate I use is for IoT Core. Did you visit: boto3.amazonaws.com/v1/documentation/api/latest/guide/… ?
    • Azhwani
      Azhwani over 5 years
      Hello @Rubens_Z, yes i tried to follow all the required steps but what i dont understand is the relation between IoT Core certificate and the python script. I'm trying to run the script in a linux server (centos). I just create a IoT Core certificate, I download the cert files but i dont know what to do with them! Can you point me to the right direction please ?
    • razimbres
      razimbres over 5 years
      There's no relation between IoT Core and boto3 connecting to EC2. I used IoT Core just as an example.
    • Azhwani
      Azhwani over 5 years
      I managed to fix the issue, thank u @Rubens_Z for ur support I really appreciate ur replies! I executed "aws configure" with new infos and everything worked ! Thanks again!
    • razimbres
      razimbres over 5 years
      may I post the solution or do you prefer posting it ?