Description
Describe the bug
Hi Team,
I have spent 8 hours trying to call "putBucketEncryption" , but i am getting xml malformed error. I have even try to debug sdk code but no luck, to me it seems some issue with SDK code.
Below is my code and error i am getting
Code
PutBucketEncryptionRequest putBucketEncryptionRequest = PutBucketEncryptionRequest.builder()
.bucket(bucketName)
.serverSideEncryptionConfiguration(ServerSideEncryptionConfiguration.builder()
.rules(ServerSideEncryptionRule.builder()
.applyServerSideEncryptionByDefault(ServerSideEncryptionByDefault.builder()
.sseAlgorithm(ServerSideEncryption.AES256)
.build())
.build())
.build()).build();
[log.info](http://log.info/)(putBucketEncryptionRequest.toString());
s3Client.putBucketEncryption(putBucketEncryptionRequest);
Error I am getting
software.amazon.awssdk.services.s3.model.S3Exception: This happens when the user sends a malformed xml (xml that doesn't conform to the published xsd) for the configuration.
The error message is, ```"The XML you provided was not well-formed or did not validate against our published schema."
(Service: S3, Status Code: 400, Request ID: 0aad0e37:17dcaa17c52:126cf8:48c, Extended Request ID: )```
Even I get the below xml while debugging SDK code, which also looks fine. I dont know why sdk is behaving like this.
<?xml version="1.0" encoding="UTF-8"?>
<ServerSideEncryptionConfiguration
xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Rule>
<ApplyServerSideEncryptionByDefault>
<SSEAlgorithm>AES256</SSEAlgorithm>
</ApplyServerSideEncryptionByDefault>
</Rule>
</ServerSideEncryptionConfiguration>
Expected Behavior
The putBucketEncryption request should have to return successful response and enable encryption on my bucket.
Current Behavior
I am getting below error
software.amazon.awssdk.services.s3.model.S3Exception: This happens when the user sends a malformed xml (xml that doesn't conform to the published xsd) for the configuration. The error message is, "The XML you provided was not well-formed or did not validate against our published schema." (Service: S3, Status Code: 400, Request ID: 0aad0e37:17dcaa17c52:126cf8:48c, Extended Request ID: )
Reproduction Steps
Just run this below code and you will get the error
PutBucketEncryptionRequest putBucketEncryptionRequest = PutBucketEncryptionRequest.builder()
.bucket(bucketName)
.serverSideEncryptionConfiguration(ServerSideEncryptionConfiguration.builder()
.rules(ServerSideEncryptionRule.builder()
.applyServerSideEncryptionByDefault(ServerSideEncryptionByDefault.builder()
.sseAlgorithm(ServerSideEncryption.AES256)
.build())
.build())
.build()).build();
[log.info](http://log.info/)(putBucketEncryptionRequest.toString());
s3Client.putBucketEncryption(putBucketEncryptionRequest);
Possible Solution
No response
Additional Information/Context
No response
AWS Java SDK version used
2.16.60
JDK version used
1.8.0_311
Operating System and version
Windows 10 Enterprise