Fix handling of SSE-C keys when copying unencrypted to encrypted objects or objects with different keys #9559
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue #, if available: #6012, and supersedes #8345
Description of changes: When copying a file that originates in S3, the high level
aws s3
commands make aHeadObject
call for the file that is being copied.When using server-side encryption with customer-provided keys (SSE-C), callers can specify the key for the source object(s)
--sse-c-copy-source
/--sse-c-copy-source-key
and/or the destination object (--sse-c
/--sse-c-key
).The CLI is incorrectly handling this for S3 -> S3 copies, by applying destination key to the copy source object.
aws s3 cp s3://$bucket/file.txt s3://$bucket/ssec-copy-c.txt --sse-c AES256 --sse-c-key $key_1
aws s3 cp s3://$bucket/ssec.txt s3://$bucket/ssec-copy-diff-key.txt --sse-c-copy-source AES256 --sse-c-copy-source-key $key_1 --sse-c AES256 --sse-c-key $key_2
Arguably Incorrect Behavior, Leaving for Backwards Compatibility
I think we're arguably handling S3 -> local copies as well.
aws s3 cp s3://$bucket/ssec.txt decrypt.txt --sse-c AES256 --sse-c-key $key_1
works, but I can see a case for applying--sse-c-copy-source
/--sse-c-copy-source-key
to the object that's originating to S3. But I'm preserving this behavior for backwards compatibility, the updated logic only runs for S3 -> S3 copies.Manual Testing
I didn't add new integration tests, but manually ran the following
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.