terricain / aioboto3

Wrapper to use boto3 resources with the aiobotocore async backend
Apache License 2.0
719 stars 74 forks source link

SSE-C encryption doesn't work with a multipart upload #271

Closed mcproger closed 3 months ago

mcproger commented 2 years ago

Description

Hello!

SSE-C encryption (Server Side Encryption with Customer provided key) doesn't work well with a multipart upload. It fails with an error botocore.exceptions.ClientError: An error occurred (InvalidRequest) when calling the UploadPart operation: The multipart upload initiate requested encryption. Subsequent part requests must include the appropriate encryption parameters.

The same code snippet works well in the sync version boto3.

What I Did

async with session.client(
    's3',
    aws_access_key_id=access_key_id,
    aws_secret_access_key=secret_access_key,
    region_name=region,
) as session:
    await destination_s3.upload_fileobj(
        raw_stream,
        Bucket=bucket,
        Key=key,
        ExtraArgs={
            'ACL': 'bucket-owner-full-control',
            'SSECustomerAlgorithm': 'AES256',
            'SSECustomerKey': KEY
        },
    )
terricain commented 2 years ago

Ah yeah, I have an idea why that might not work. Will look into it on the weekend if I get a chance.

terricain commented 2 years ago

Can you try version 10.0.1a0 and see if that fixes it for you?

terricain commented 3 months ago

This should be fixed as part of v13.0.0, if not, please re-open