Skip to content

Commit c078643

Browse files
m
1 parent 12a2e13 commit c078643

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

src/main/java/software/amazon/encryption/s3/internal/PutEncryptedObjectPipeline.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public CompletableFuture<PutObjectResponse> putObject(PutObjectRequest request,
8484
.overrideConfiguration(API_NAME_INTERCEPTOR)
8585
.contentLength(encryptedContent.getCiphertextLength())
8686
.build();
87-
return _s3AsyncClient.putObject(encryptedPutRequest, encryptedContent.getAsyncCiphertext());
87+
return _s3AsyncClient.putObject(encryptedPutRequest, new NoRetriesAsyncRequestBody(encryptedContent.getAsyncCiphertext()));
8888
}
8989

9090
public static class Builder {

src/test/java/software/amazon/encryption/s3/S3EncryptionClientTest.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import com.amazonaws.services.s3.model.StaticEncryptionMaterialsProvider;
1818
import org.bouncycastle.jce.provider.BouncyCastleProvider;
1919
import org.junit.jupiter.api.BeforeAll;
20+
import org.junit.jupiter.api.Test;
2021
import org.junitpioneer.jupiter.RetryingTest;
2122
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
2223
import software.amazon.awssdk.auth.credentials.AwsSessionCredentials;
@@ -966,7 +967,7 @@ public void s3EncryptionClientTopLevelCredentialsWrongRegion() {
966967
}
967968
}
968969

969-
@RetryingTest(3)
970+
@Test
970971
public void crossRegionRoundTrip() {
971972
final String objectKey = appendTestSuffix("cross-region-test");
972973
SecretKeySpec aesKey = new SecretKeySpec(new byte[32], "AES");
@@ -980,14 +981,12 @@ public void crossRegionRoundTrip() {
980981

981982
try {
982983
PutObjectRequest request = PutObjectRequest.builder().bucket(BUCKET).key(objectKey).build();
983-
s3.putObject(request, RequestBody.fromBytes("test".getBytes()));
984-
ResponseBytes<GetObjectResponse> response = s3.getObjectAsBytes(builder -> builder
985-
.bucket(BUCKET)
986-
.key(objectKey)
987-
.build());
988-
assertEquals("test", response.asUtf8String());
984+
S3EncryptionClientException ex = assertThrows(S3EncryptionClientException.class, () ->
985+
s3.putObject(request, RequestBody.fromBytes("test".getBytes())));
986+
// Cross-region redirect causes the SDK to re-subscribe to the request body.
987+
// NoRetriesAsyncRequestBody blocks this to prevent GCM cipher key/IV reuse.
988+
assertTrue(ex.getMessage().contains("Re-subscription is not supported"));
989989
} finally {
990-
deleteObject(BUCKET, objectKey, s3);
991990
s3.close();
992991
}
993992
}

0 commit comments

Comments
 (0)