Intermittent SignatureDoesNotMatch while using presigned s3 url

0

Hello, I would appreciate your guidance on SignatureDoesNotMatch error thrown when trying to Put an object using presigned s3 url.

We have a .Net 6 microservice api, running on ecs cluster. The api running on the container gets its credentials for accessing the S3 bucket, from the task role assigned. We were getting intermittent errors of ExpiredToken. I believe there was a bug in the aws sdk version that is responsible for renewing the credentials before they expire, reference: ECSTaskCredentials refreshes too late · Issue #2498 · aws/aws-sdk-net (github.com)

We updated the awssdk.s3 version from 3.7.9.1 to 3.7.305.30. and updated the role session to be a maximum of 12 hours, instead of the previous 1-hour session.

The client code in the api is as follows:

services.AddSingleton<IAmazonS3>(_ =>
			{
				var s3Config = new AmazonS3Config
				{
					RetryMode = RequestRetryMode.Standard,
					MaxErrorRetry = 5,
					SignatureVersion = "4",
					RegionEndpoint = awsContext.RegionEndpoint
				};
				return new AmazonS3Client(s3Config);
			});
GetPreSignedUrlRequest req = new GetPreSignedUrlRequest
				{
					BucketName = bucketName,
					Key = objectKey,
					Expires = expires,
					Verb = HttpVerb.PUT,
					Protocol = Protocol.HTTPS
				};
				req.Parameters.Add("x-amz-storage-class", storageClass);
				var preSignedUrl = _s3Client.GetPreSignedURL(req);

Now, we are getting SignatureDoesNotMatch error intermittently, while using the presigned url.

I would appreciate some guidance with this.

Neisha
asked a month ago302 views
1 Answer
1

💡 I recommend reading this article: How do I troubleshoot SigV4 Signature Mismatch errors with Amazon S3 presigned URLs

⚠️ And also this article on "SignatureDoesNotMatch #AWS #S3 [#Solved]". It offers detailed explanations of potential causes. You can find it here: SignatureDoesNotMatch AWS S3 Solved.

profile picture
EXPERT
answered a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions