botocore.exceptions.SSLError:SSL验证失败

2024-06-28 20:49:37 发布

您现在位置:Python中文网/ 问答频道 /正文

Python:2.7.5
Pip:pip18.1来自/usr/lib/python2.7/site-packages/Pip(python2.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 7.5.1804(核心版)

我的剧本

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

运行脚本时,出现以下异常:

  • 在botocore.exceptions.SSLError:对https://ec2.region.amazonaws.com/主机名ec2的SSL验证失败。亚马逊网站'与'*中的任何一个都不匹配。com.com网站', 'com.com网站'

如有任何帮助,将不胜感激! 谢谢!在


Tags: pipimportcomawscli网站responselinux
2条回答

我有办法解决这个问题。在

不要使用pip/pip3安装boto3。在

使用以下步骤:

$ git clone https://github.com/boto/boto3.git
$ cd boto3
$ virtualenv venv
...
$ . venv/bin/activate
$ pip install -r requirements.txt
$ pip install -e .

它对我有用。最初我也面临着同样的SSL验证异常问题。然后我卸载了boto3(pip3卸载boto3),并使用virtualenv重新安装了它。现在,它工作得很好。在

@azhwani,由于您没有使用AWS IoT Core,这似乎不是与过期证书相关的问题。在

运行:

$ aws configure

。。。并插入您的AWS证书。在

相关问题 更多 >