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
- Request checksum when required Set via boto config: request_checksum_calculation="when_required" response_checksum_validation="when_required" https://github.com/boto/boto3/issues/4400#issuecomment-2... — committed to opnfv/functest-xtesting by collivier 2 years ago
- Request checksum when required Set via boto config: request_checksum_calculation="when_required" response_checksum_validation="when_required" https://github.com/boto/boto3/issues/4400#issuecomment-2... — committed to opnfv/functest-xtesting by collivier 2 years ago
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:
Changing your config to:
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_namefor the S3 client, I am unable to reproduce the error.Omitting the
region_namecauses intermittent failures - sometimes it works, sometimes it doesn’t work.