问题
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!
回答1:
@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.
回答2:
I have got the solution for this.
Don't install boto3 using pip/pip3.
Use following steps::
$ git clone https://github.com/boto/boto3.git
$ cd boto3
$ virtualenv venv
...
$ . venv/bin/activate
$ pip install -r requirements.txt
$ pip install -e .
It worked for me. Initially I was facing the same SSL Validation Exception problem. Then I uninstalled the boto3 (pip3 uninstall boto3) and re-installed it using virtualenv as stated above. Now, it is working fine.
来源:https://stackoverflow.com/questions/54690347/botocore-exceptions-sslerror-ssl-validation-failed