10

In aws-sdk v2 for javascript, we instantiate s3 client using:

var s3  = new AWS.S3({
          accessKeyId: 'YOUR-ACCESSKEYID' ,
          secretAccessKey: 'YOUR-SECRETACCESSKEY' ,
          s3ForcePathStyle: true,
          signatureVersion: 'v4'
});  

Here you can see the signatureVersion being able to be specified.

In v3 you instantiate the client using:

import { S3Client } from '@aws-sdk/client-s3';

credentials = {  
    accessKeyId: <ACCESS_KEY>,
    secretAccessKey: <SECRET_ACCESS_KEY>
  }
const client = new S3Client({
        region: 'us-east-1',
        credentials: credentials,
        forcePathStyle: true,
    })  

The docs aren't very clear (and without an example) on how to do this. How would I specify the signatureVersion for the client in this versin(v3) of the sdk?

2 Answers 2

5

I've just migrated from the old to new s3 client.

I previously had to specify signatureVersion: 'v4' because of this issue (we had to upload files with whitespaces).

I have not had this issue since migrating, so I think it's safe to assume they use version 4 signatures by default.

And since they don't expose a signatureVersion config option, I would say it's also safe to assume you can't use signature version 2 using the the new SDK.

--

[Edit] Check their docs: https://docs.aws.amazon.com/AmazonS3/latest/API/bucket-policy-s3-sigv4-conditions.html

"AWS" identifies Signature Version 2

"AWS4-HMAC-SHA256" identifies Signature Version 4

So you should be able to check the X-Amz-Algorithm query param to make sure.

Sign up to request clarification or add additional context in comments.

Comments

1

On this page they say:

For all AWS Regions, AWS SDKs use Signature Version 4 by default to authenticate requests. When using AWS SDKs that were released before May 2016, you might be required to request Signature Version 4, as shown in the following table.

Since the v3 SDK was released in 2020, it should use Signature Version 4.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.