gpt4 book ai didi

python - botocore.exceptions.SSLError : SSL validation failed on WIndows

转载 作者:行者123 更新时间:2023-12-04 11:50:27 29 4
gpt4 key购买 nike

以下代码用于获取区域。

import boto3
ec2 = boto3.client('ec2', 'region-name')
print(ec2.describe_regions())
在我的机器上执行此代码时,我收到此错误。

botocore.exceptions.SSLError: SSL validation failed for https://ec2.region-name.amazonaws.com/ [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)


我在带有 的 Windows 10 机器上运行此代码VS码作为我的编辑。我在他们需要安装 Install Certificates.command 的地方寻找其他答案文件。但是,看起来它只能在 macOS 上找到。
有人能告诉我这个问题的原因吗?
此外,上周收到来自 AWS 的通知,他们正在将所有 AWS FIPS 端点更新为 TLS 1.2
因此需要连接到 TLS 版本 1.2 FIPS 端点。我检查了我的 TLS 版本 here .它说我有 TLS 1.2 版。有什么相关的吗?因为在此通知之前,我的脚本运行良好。
请有人告诉这个错误的原因和可能的更正。另外,如果我提到我的理解有问题,请纠正我。

最佳答案

[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate是因为 Python ssl库无法在您的本地计算机上找到要验证的证书。
一种调试方法是查看您是否有 ca_bundle设置为其他内容:

python -c "from botocore.session import Session; print(Session().get_config_variable('ca_bundle'))"
如果它不打印任何东西,那么它使用默认路径。您可以通过以下方式检查默认路径:
python -c "import ssl; print(ssl.get_default_verify_paths())"
如果 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

关于python - botocore.exceptions.SSLError : SSL validation failed on WIndows,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63557500/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com