shr*_*kar 6 python ssl amazon-web-services boto3
以下代码用于获取区域。
import boto3
ec2 = boto3.client('ec2', 'region-name')
print(ec2.describe_regions())
Run Code Online (Sandbox Code Playgroud)
在我的机器上执行此代码时,我收到此错误。
botocore.exceptions.SSLError:https ://ec2.region-name.amazonaws.com/ 的 SSL 验证失败[SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败:无法获取本地颁发者证书 (_ssl.c:1108)
我在 Windows 10 机器上使用VS 代码作为我的编辑器运行此代码。我在他们需要安装Install Certificates.command文件的地方寻找其他答案。但是,看起来它只能在 macOS 上找到。
有人可以告诉我这个问题的原因吗?
此外,上周收到来自 AWS 的通知,称他们正在将所有 AWS FIPS 端点更新为 TLS 1.2,因此需要连接到 TLS 1.2 版 FIPS 端点。我在这里检查了我的 TLS 版本。它说我有 TLS 1.2 版。有什么与此有关的吗?因为在此通知之前,我的脚本运行良好。
请有人告诉这个错误的原因和可能的更正。另外,如果我提到我的理解有问题,请纠正我。
cak*_*aww 17
[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate是因为 Pythonssl库无法在本地计算机上找到要验证的证书。
调试的一种方法是查看您是否ca_bundle设置了其他内容:
python -c "from botocore.session import Session; print(Session().get_config_variable('ca_bundle'))"
Run Code Online (Sandbox Code Playgroud)
如果它不打印任何内容,则它使用默认路径。您可以通过以下方式检查默认路径:
python -c "import ssl; print(ssl.get_default_verify_paths())"
Run Code Online (Sandbox Code Playgroud)
如果ca_bundle打印某些内容,则它是由AWS_CA_BUNDLE环境变量或aws configure set default.ca_bundle <some path>过去设置的。另请检查~/.aws/config您是否不小心将其设置在那里(Windows 的配置文件位置: https: //docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html)。
Install Certificates.command基本上是一个Python脚本,你可以自己运行https://gist.github.com/marschhuynh/31c9375fc34a3e20c2d3b9eb8131d8f3。另存为install-cert.py并运行python install-cert.py
| 归档时间: |
|
| 查看次数: |
9929 次 |
| 最近记录: |