This is an automated email from the ASF dual-hosted git repository.

oscerd pushed a commit to branch camel-4.18.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-4.18.x by this push:
     new b1b94fc6d90f CAMEL-21314: camel-aws2-s3 - supply the customer key when 
copying SSE-C objects (camel-4.18.x backport) (#25044)
b1b94fc6d90f is described below

commit b1b94fc6d90f4bca7c364f287e2037cbbc45a338
Author: Andrea Cosentino <[email protected]>
AuthorDate: Thu Jul 23 11:01:35 2026 +0200

    CAMEL-21314: camel-aws2-s3 - supply the customer key when copying SSE-C 
objects (camel-4.18.x backport) (#25044)
    
    Backport of #25027 to camel-4.18.x. Also sets 
copySourceSSECustomerKey/MD5/Algorithm on copyObject and re-enables 
S3CopyObjectCustomerKeyIT (verified against localstack).
    
    Co-authored-by: Claude Fable 5 <[email protected]>
---
 .../main/java/org/apache/camel/component/aws2/s3/AWS2S3Producer.java | 5 +++++
 .../component/aws2/s3/integration/S3CopyObjectCustomerKeyIT.java     | 2 --
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git 
a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Producer.java
 
b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Producer.java
index 7dfc50df801b..15bc37a25a68 100644
--- 
a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Producer.java
+++ 
b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Producer.java
@@ -506,13 +506,18 @@ public class AWS2S3Producer extends DefaultProducer {
             }
 
             if (getConfiguration().isUseCustomerKey()) {
+                // the source object was stored with SSE-C, so the same 
customer key must also be supplied as the
+                // copy-source key, otherwise S3 cannot decrypt the source and 
rejects the copy
                 if 
(ObjectHelper.isNotEmpty(getConfiguration().getCustomerKeyId())) {
+                    
copyObjectRequest.copySourceSSECustomerKey(getConfiguration().getCustomerKeyId());
                     
copyObjectRequest.sseCustomerKey(getConfiguration().getCustomerKeyId());
                 }
                 if 
(ObjectHelper.isNotEmpty(getConfiguration().getCustomerKeyMD5())) {
+                    
copyObjectRequest.copySourceSSECustomerKeyMD5(getConfiguration().getCustomerKeyMD5());
                     
copyObjectRequest.sseCustomerKeyMD5(getConfiguration().getCustomerKeyMD5());
                 }
                 if 
(ObjectHelper.isNotEmpty(getConfiguration().getCustomerAlgorithm())) {
+                    
copyObjectRequest.copySourceSSECustomerAlgorithm(getConfiguration().getCustomerAlgorithm());
                     
copyObjectRequest.sseCustomerAlgorithm(getConfiguration().getCustomerAlgorithm());
                 }
             }
diff --git 
a/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/integration/S3CopyObjectCustomerKeyIT.java
 
b/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/integration/S3CopyObjectCustomerKeyIT.java
index 182f53d3dff5..49f140244d34 100644
--- 
a/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/integration/S3CopyObjectCustomerKeyIT.java
+++ 
b/components/camel-aws/camel-aws2-s3/src/test/java/org/apache/camel/component/aws2/s3/integration/S3CopyObjectCustomerKeyIT.java
@@ -32,7 +32,6 @@ import org.apache.camel.component.aws2.s3.AWS2S3Constants;
 import org.apache.camel.component.aws2.s3.AWS2S3Operations;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
 import software.amazon.awssdk.services.s3.model.GetObjectRequest;
 import software.amazon.awssdk.utils.Md5Utils;
@@ -41,7 +40,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.fail;
 import static 
software.amazon.awssdk.services.s3.model.ServerSideEncryption.AES256;
 
-@Disabled("Broken test")
 public class S3CopyObjectCustomerKeyIT extends Aws2S3Base {
 
     byte[] secretKey = generateSecretKey();

Reply via email to