草庐IT

python - 博托 [SSL : CERTIFICATE_VERIFY_FAILED] certificate verify failed while connecting to S3

coder 2023-08-16 原文

我正在尝试使用 boto 连接到 S3,但它似乎失败了。我尝试了一些解决方法,但它们似乎不起作用。谁能帮我解决这个问题。下面是代码。

import boto

if not boto.config.has_section('Credentials'):
    boto.config.add_section('Credentials')
boto.config.set('Credentials', 'aws_access_key_id', AWS_KEY)
boto.config.set('Credentials', 'aws_secret_access_key', AWS_SECRET_KEY)
if not boto.config.has_section('Boto'):
    boto.config.add_section('Boto')
    boto.config.set('Boto', 'https_validate_certificates', 'False')
    boto.config.add_section('aws info')
    boto.config.set('aws info','aws_validate_certs','False')



s3 = boto.connect_s3(validate_certs=False)
bucket = s3.get_bucket(Bucket_NAME)

最佳答案

可能您的存储桶名称包含一个点,这就是 ssl 证书验证失败的原因。这是一个很常见的问题,请参阅此 github issue例如。

不要使用不安全的连接(is_secure=False),而是使用OrdinaryCallingFormat:

import boto
conn = boto.s3.connect_to_region('eu-west-1', calling_format=boto.s3.connection.OrdinaryCallingFormat())
bucket = conn.get_bucket(your_bucket)

您可能需要更新您的 AWS Region ,例如us-east-1

关于python - 博托 [SSL : CERTIFICATE_VERIFY_FAILED] certificate verify failed while connecting to S3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28115250/

有关python - 博托 [SSL : CERTIFICATE_VERIFY_FAILED] certificate verify failed while connecting to S3的更多相关文章

随机推荐