Skip to content

CreatePresignedPostAsync appends a trailing slash to x-amz-credential, breaks SigV4 on S3-compatible servers #4069

@Berreip

Description

@Berreip

Describe the bug

AmazonS3Client.CreatePresignedPostAsync generates x-amz-credential as:
<AccessKey>/<YYYYMMDD>/<region>/s3/aws4_request/
AWS docs define the scope without a trailing slash. Example: …/aws4_request only. Strict S3-compatible services (like Minio) reject the extra / during SigV4 parsing.
AWS Documentation POST

Code reference
File: sdk/src/Services/S3/Custom/Util/S3PostUploadSignedPolicy.cs S3PostUploadSignedPolicy.cs
Line 123:

var credentialString = string.Format(CultureInfo.InvariantCulture, "{0}/{1}/{2}/{3}/{4}/", iCreds.AccessKey, dateStamp, region, "s3", Runtime.Internal.Auth.AWS4Signer.Terminator); 

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

x-amz-credential follows AWS SigV4 scope format: YYYYMMDD/region/service/aws4_request (no trailing slash).
aws reference_sigv-signing-elements

Current Behavior

x-amz-credential includes a trailing slash.

Reproduction Steps

  1. Build a CreatePresignedPostRequest and call CreatePresignedPostAsync.
  2. POST the returned form to a SigV4-strict S3-compatible server.
  3. Receive AuthorizationQueryParametersError about date parsing. Logged fields show x-amz-credential ends with /.

Possible Solution

Emit x-amz-credential without the trailing slash, or provide an option to do so, to match AWS documentation and improve interoperability.

Additional Information/Context

No response

AWS .NET SDK and/or Package version used

AWSSDK.S3 4.0.7.13

Targeted .NET Platform

.Net Core 9

Operating System and version

Windows 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.p2This is a standard priority issuequeueds3xsEffort estimation: tiny

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions