Archish J
Archish J

Reputation: 19

Trying to upload images to my AWS S3 bucket using AWS-shell

The following is my python script to upload the code.


s3 = boto3.resource('s3')

# Get list of objects for indexing
images=[('Micheal_Jordan.jpg','Micheal Jordan'),
      ('Wayne_Rooney.jpg','Wayne Rooney')
      ]

# Iterate through list to upload objects to S3
for image in images:
    file = open(image[0],'rb')
    object = s3.Object('famouspersons-images','index/'+ image[0])
    ret = object.put(Body=file,
                    Metadata={'FullName':image[1]})

Getting the following error.

botocore.exceptions.SSLError: SSL validation failed for https://s3bucketname.s3.amazonaws.com/index/Wayne_Rooney.jpg [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)

Upvotes: 1

Views: 185

Answers (1)

Chaitanya
Chaitanya

Reputation: 3638

This error occurs because Python SSL library can't find certificates on your local machine to verify against.

You can check if you have your ca_bundle set to something else:

python -c "from botocore.session import Session; print(Session().get_config_variable('ca_bundle'))"

If it doesn't print anything, then it uses default path. You can check default path by:

python -c "import ssl; print(ssl.get_default_verify_paths())"

If something is printed on the screen, then it was set by AWS_CA_BUNDLE environment variable or by aws configure set default.ca_bundle <some path> in the past.

You can install certificates by following https://gist.github.com/marschhuynh/31c9375fc34a3e20c2d3b9eb8131d8f3. Then you can save it as install-cert.py and run then run python install-cert.py.

If this does not work out, you can try the following solutions:

Upvotes: 2

Related Questions