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 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则