Boto: [bug][S3] `boto.s3.Key.encrypted` does not return True for encrypted keys

Created on 10 Jul 2015  Â·  3Comments  Â·  Source: boto/boto

Steps to reproduce:

  1. Create a bucket if one does not already exist
  2. Upload a file to the bucket

    • set the 'x-amz-server-side​-encryption': 'AES256' header either by Bucket.Key.generate_ur or manually

      Expected:

  3. new_key.encrypted should return True

  4. new_key.encrypted returns nothing

    Notes:

  • SS working with the Key in IPython
    screen shot 2015-07-10 at 5 05 16 pm
  • SS confirming SSE-S3
    screen shot 2015-07-10 at 5 05 41 pm
bug s3

Most helpful comment

I too can duplicate this behavior.

All 3 comments

I think this issue is not directly related to "[feature] Allow new S3 keys to be encrypted". This issue is when retrieving keys from backet, key.encrypted doesn't reflect actual encryption value. E.g I have an email which is server side encrypted but when I print key.encrypted, it returns None.

keys = bucket.list()
for k in keys:
    print k.name, k.size, k.last_modified, k.encrypted , "\n"

Here k.encrypted encrypted is None

I too can duplicate this behavior.

Running into the same problem here. Please either fix, or update the docs so people are not led down this rabbit hole for 2+ years.

The only place the AES256 header literal is parsed is Key.handle_encryption_headers(). However, that's only called on Key.open_read() which requires that you try to read the key's content. As such, the listing of keys will not return this value, despite the documentation's claim.

The reason this "doesn't work" as documented, is likely because the API S3 ListObjects API call does not return encryption type. As such, the simplest resolution is to make clear in the documentation that this is not available from the bucket.list() and bucket.get_all_keys() methods.

Was this page helpful?
0 / 5 - 0 ratings