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
질문됨 한 달 전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
전문가
답변함 한 달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인