boto3: PutObject fails with SignatureDoesNotMatch following release of 1.36

Describe the bug

We’re seeing intermittent signature errors when using boto3==1.36.x and botocore==1.36.x with S3 transfer acceleration enabled. Either disabling transfer acceleration or downgrading to boto3==1.35.99 allows the upload to succeed.

botocore.exceptions.ClientError: An error occurred (SignatureDoesNotMatch) when calling the PutObject operation: The request signature we calculated does not match the signature you provided. Check your key and signing method.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

PutObject call succeeds without error.

Current Behavior

Intermittent SignatureDoesNotMatch errors

Reproduction Steps


client = boto3_session.client(
    service_name="s3",
    config=Config(
        s3={
            "use_accelerate_endpoint": True,
        },
        signature_version='s3v4',
    ),
)

client.upload_file(
    local_path, 
    bucket_name,
    upload_path, 
    ExtraArgs={
        "ContentType": mimetype,
    },
)

Possible Solution

No response

Additional Information/Context

Looking at the announcement regarding integrity checks in 1.36.x, it looks as though this may be related.

SDK version used

1.36.x

Environment details (OS name and version, etc.)

Python 3.9.4 on Ubuntu 20.04.6 LTS

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 4
  • Comments: 32 (8 by maintainers)

Commits related to this issue

Most upvoted comments

This issue is related to new parameters of the Config, which are not yet supported by third-party S3-compatible providers. As stated in Reference:

request_checksum_calculation (str) –
Determines when a checksum will be calculated for request payloads. Valid values are:

when_supported – When set, a checksum will be calculated for all request payloads of operations modeled with the httpChecksum trait where requestChecksumRequired is true or a requestAlgorithmMember is modeled.
when_required – When set, a checksum will only be calculated for request payloads of operations modeled with the httpChecksum trait where requestChecksumRequired is true or where a requestAlgorithmMember is modeled and supplied.
Defaults to None.

response_checksum_validation (str) –
Determines when checksum validation will be performed on response payloads. Valid values are:

when_supported – When set, checksum validation is performed on all response payloads of operations modeled with the httpChecksum trait where responseAlgorithms is modeled, except when no modeled checksum algorithms are supported.
when_required – When set, checksum validation is not performed on response payloads of operations unless the checksum algorithm is supported and the requestValidationModeMember member is set to ENABLED.

Changing your config to:

s3_client = boto3.client(
     's3',
     endpoint_url=os.getenv('S3_ENDPOINT'),
     config=Config(request_checksum_calculation="when_required", response_checksum_validation="when_required")
 )

fixes the problem.

@jonathan343 this issue seems to be related to third-party S3 providers only.

Morning all,

Just following up, I’ve been running my test script daily and I’m still able to reliably trigger the issue. Given that you say it’s an S3 server-side issue, would you like me to raise a AWS support ticket for “Production system impaired”?

Cheers, David

I might have found another clue - in the debug logs, it indicated that boto3 was correcting the region for the bucket early on in the request. After explicitly setting the region_name for the S3 client, I am unable to reproduce the error.

Omitting the region_name causes intermittent failures - sometimes it works, sometimes it doesn’t work.