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
已提問 1 個月前檢視次數 291 次
1 個回答
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
專家
已回答 1 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南