amazon-web-servicesamazon-s3aws-java-sdk-2.x

Drop checksum header on AWS Java SDK 2 >= 2.30.0


We are having this issue where since some recent update the AWS SDK for Java always sends a x-amz-content-sha256 hash header in S3 putObject requests.

That works fine with AWS but our allegedly compatible cloud provider actively does not support any form of hash check and simply returns

The provided 'x-amz-content-sha256' header does not match what was computed. (Service: S3, Status Code: 400

when they see the unsupported header.

We cannot live forever in an outdated AWS SDK client version; Is there any way to drop the header? (Looking at the documentation I see request config overrides like https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/core/client/config/ClientOverrideConfiguration.Builder.html but they only allow adding or modifying, not removing?)


Solution

  • A colleague found the right override: https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/s3/S3BaseClientBuilder.html#requestChecksumCalculation(software.amazon.awssdk.core.checksums.RequestChecksumCalculation)

    So, the fix is simple: Just add .requestChecksumCalculation(RequestChecksumCalculation.WHEN_REQUIRED) to your S3Client.builder() and it will work just as smoothly as before the update to AWS SDK >=2.30.0.