Skip to content

S3 Signed URL for Custom Domain Results in SignatureDoesNotMatch #6927

@eacet

Description

@eacet

Checkboxes for prior research

Describe the bug

I am generating a signed URL using @aws-sdk/client-s3 and @aws-sdk/s3-request-presigner for a custom domain mapped to my S3 bucket. However, when I call the signed URL, I receive a 403 Forbidden response with the following error:

Error Code: SignatureDoesNotMatch  
Error Message: The request signature we calculated does not match the signature you provided. Check your key and signing method.  

Regression Issue

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

SDK version number

@aws-sdk/[email protected], @aws-sdk/[email protected]

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

nodejs18.x

Reproduction Steps

  1. Code Used to Generate Signed URL:
import { S3, GetObjectCommand } from '@aws-sdk/client-s3';
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';

async function buildSignedUrl() {
    const s3 = new S3({
        region: 'eu-west-1',
        bucketEndpoint: true,    
});

    const command = new GetObjectCommand({
        Bucket: 'my-custom-domain',
        Key: 'my-file-key',
    });

    const signedUrl = await getSignedUrl(s3, command, { expiresIn: 3600 });
    console.log(signedUrl);
    return signedUrl;
}
  1. Signed URL is generated successfully and appears correct.
  2. Calling the Signed URL using curl or a browser results in:
<Error>
  <Code>SignatureDoesNotMatch</Code>
  <Message>The request signature we calculated does not match the signature you provided.</Message>
</Error>

Observed Behavior

Signed URL results in a 403 Forbidden with SignatureDoesNotMatch.

Expected Behavior

It should download file.

Possible Solution

No response

Additional Information/Context

No response

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.closed-for-stalenessp2This is a standard priority issueresponse-requestedWaiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions