fix(s3): apply the destination bucket's default encryption to CopyObject (#9211)

A CopyObject whose request names no encryption now takes the destination bucket's default
encryption, as the CopyObject reference says, not the source object's encryption. An explicit
encryption header on the copy request and an SSE-C destination key keep their precedence, and an
explicit aws:kms:dsse copy keeps its key id. S3IntegrationTest.copyObjectPreservesServerSideEncryption
is renamed and changed to match.
This commit is contained in:
glorfindel33 authored and GitHub committed 2026-11-22 14:46:04 -04:00
1 parent ee722e8da3
commit 78ea3c90d9
5 files changed
+139 -16

No files matched your search

@@ -8707,14 +8707,7 @@ public class S3Service implements Resettable, ResourceProvider {
String effectiveCacheControl = replaceMetadata && effectiveOptions.getCacheControl() != null
? effectiveOptions.getCacheControl()
: source.getCacheControl();
String effectiveServerSideEncryption = destinationCustomerKey != null
? null
: (normalizedServerSideEncryption != null ? normalizedServerSideEncryption : source.getServerSideEncryption());
String effectiveSseKmsKeyId = "aws:kms".equals(effectiveServerSideEncryption)
? (normalizedServerSideEncryption != null
? effectiveOptions.getSseKmsKeyId()
: source.getSseKmsKeyId())
: null;
String effectiveSseKmsKeyId = effectiveOptions.getSseKmsKeyId();
boolean replaceTags = "REPLACE".equalsIgnoreCase(effectiveOptions.getTaggingDirective());
Map<String, String> effectiveTags = replaceTags
? effectiveOptions.getReplacementTagging()
@@ -8769,7 +8762,7 @@ public class S3Service implements Resettable, ResourceProvider {
}
result[0] = storeObjectCopy(destBucket, destKey, body, metadata,
effectiveContentType, effectiveStorageClass, effectiveContentEncoding,
effectiveContentDisposition, effectiveCacheControl, effectiveServerSideEncryption,
effectiveContentDisposition, effectiveCacheControl, normalizedServerSideEncryption,
effectiveSseKmsKeyId, effectiveOptions, copyChecksumAlgorithm, effectiveTags);
if (copyAnnotations) {
restoreAnnotations(sourceAnnotations, destBucket, destKey, result[0]);
@@ -8793,7 +8786,7 @@ public class S3Service implements Resettable, ResourceProvider {
.orElseThrow(() -> noSuchBucket())) {
result[0] = storeObjectCopy(destBucket, destKey, body, metadata,
effectiveContentType, effectiveStorageClass, effectiveContentEncoding,
effectiveContentDisposition, effectiveCacheControl, effectiveServerSideEncryption,
effectiveContentDisposition, effectiveCacheControl, normalizedServerSideEncryption,
effectiveSseKmsKeyId, effectiveOptions, copyChecksumAlgorithm, effectiveTags);
if (copyAnnotations) {
restoreAnnotations(sourceAnnotations, destBucket, destKey, result[0]);