• Register
0 votes
492 views

Problem :

I am facing following AWS error
the authorization mechanism you have provided is not supported. please use aws4-hmac-sha256.
6 5 3
6,930 points

Please log in or register to answer this question.

2 Answers

0 votes

Solution :

I guess the error occured because you were using old version of aws-sdk and after that you updated the version and this error started occuring.

So with node js you should use the signatureVersion in parmas object as following :

e.g.

const AWS_S3 = new AWS.S3({
  params: {
    Bucket: process.env.AWS_S3_BUCKET,
    signatureVersion: 'v4',
    region: process.env.AWS_S3_REGION
  }
});

Then you need to put the signature out of the params object as shown below and it should work for you :

const AWS_S3 = new AWS.S3({
  params: {
    Bucket: process.env.AWS_S3_BUCKET,
    region: process.env.AWS_S3_REGION
  },
  signatureVersion: 'v4'
});
9 7 4
38,600 points
0 votes

Solution:

AWS4-HMAC-SHA256 is  known as Signature Version 4, ("V4") is one of two authentication schemes supported by S3.

All regions support V4, However US-Standard¹, and many -- but not all -- other regions, also support the other, older scheme, Signature Version 2 ("V2").

Follw this code, with node

var s3 = new AWS.S3( {
    endpoint: 's3-eu-central-1.amazonaws.com',
    signatureVersion: 'v4',
    region: 'eu-central-1'
} );

You must set signatureVersion: 'v4' in config to use new sign version:

AWS.config.update({
    signatureVersion: 'v4'
});

Works for JS sdk.

For people using boto3 (Python SDK) use the below code

from botocore.client import Config


s3 = boto3.resource(
    's3',
    aws_access_key_id='xxxxxx',
    aws_secret_access_key='xxxxxx',
    config=Config(signature_version='s3v4')
)

Similar cause with the PHP SDK, this will work:

$s3Client = S3Client::factory(array('key'=>YOUR_AWS_KEY, 'secret'=>YOUR_AWS_SECRET, 'signature' => 'v4', 'region'=>'eu-central-1'));

The important bit is the signature and the region

AWS_S3_REGION_NAME = "ap-south-1"

Or previous to boto3 version 1.4.4:

AWS_S3_REGION_NAME = "ap-south-1"

AWS_S3_SIGNATURE_VERSION = "s3v4"

In Java I had to set a property

System.setProperty(SDKGlobalConfiguration.ENFORCE_S3_SIGV4_SYSTEM_PROPERTY, "true")

and include the region to the s3Client instance.

s3Client.setRegion(Region.getRegion(Regions.EU_CENTRAL_1))

With boto3, this is the code :

s3_client = boto3.resource('s3', region_name='eu-central-1')

or

s3_client = boto3.client('s3', region_name='eu-central-1')

For thumbor-aws, that used boto config, i needed to put this to the $AWS_CONFIG_FILE

[default]
aws_access_key_id = (your ID)
aws_secret_access_key = (your secret key)
s3 =
    signature_version = s3

For Android SDK, setEndpoint solves the problem, although it's been deprecated.

CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(
                context, "identityPoolId", Regions.US_EAST_1);
AmazonS3 s3 = new AmazonS3Client(credentialsProvider);
s3.setEndpoint("s3.us-east-2.amazonaws.com");

Basically the error was because I was using old version of aws-sdk and I updated the version so this error occured.

in my case with node js i was using signatureVersion in parmas object like this :

const AWS_S3 = new AWS.S3({
  params: {
    Bucket: process.env.AWS_S3_BUCKET,
    signatureVersion: 'v4',
    region: process.env.AWS_S3_REGION
  }
});

Then I put signature out of params object and worked like charm :

const AWS_S3 = new AWS.S3({
  params: {
    Bucket: process.env.AWS_S3_BUCKET,
    region: process.env.AWS_S3_REGION
  },
  signatureVersion: 'v4'
});

Check your AWS S3 Bucket Region and Pass proper Region in Connection Request.

using (var client = new AmazonS3Client(awsAccessKeyId, awsSecretAccessKey, RegionEndpoint.APSouth1))
{
    GetPreSignedUrlRequest request1 = new GetPreSignedUrlRequest
    {
        BucketName = bucketName,
        Key = keyName,
        Expires = DateTime.Now.AddMinutes(50),
    };
    urlString = client.GetPreSignedURL(request1);
}

 

10 6 4
31,120 points

Related questions

0 votes
1 answer 552 views
552 views
Problem : I am new to Lambda and want to setup my Lambda to access my Mongo server on one of the EC2 instances in VPC. I tried selecting all the subnets and security groups, but still I am getting the following error while trying to save "You are not authorized to perform: ... very hard to add IAM role to my account. Please let me know what policy/role I need to add for this problem to be fixed?
asked Nov 21, 2019 peterlaw 6.9k points
0 votes
0 answers 95 views
95 views
Problem: I have only managed to have the elementary knowledge on AWS. Currently I am trying to download all of the available files from the s3 bucket to the local machine. I have already installed AWS cli. After that I have tried to use the aws configure to ... the ListObjectsV2 operation: The AWS Access Key Id you provided does not exist in our records. Kindly guide me in fixing above AWS error.
asked Jun 22, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 103 views
103 views
Problem : I have searched on a web for over two days now, and probably have looked through most of a online documented scenarios and workarounds, but nothing realy worked for me so far. I am on a AWS SDK for PHP V2.8.7 running on PHP 5.3. I want to ... pass in the information (example: profile and including credentials in code) but nothing is working at the moment for me. Any solution on my error?
asked Jan 18, 2020 jwilliam 3.9k points
0 votes
1 answer 37 views
37 views
Problem : I have created a project on my old laptop using rails and heroku. I am trying to access the files and push the new edits to heroku on my laptop. Luckily they are all saved on Git so I can clone the git repository onto my new laptop. My new laptop had ... nightmare for me and I just want to find a correct way to install ruby and rails so that above mentioned errors will get out the way.
asked Nov 28, 2019 alecxe 7.5k points
0 votes
1 answer 190 views
190 views
Problem : I am trying to install the gem using gem install mygem or update a RubyGems using gem update --system, and it fails with below error: ERROR:  While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory. Does anyone have the idea how to fix this error?
asked Jan 22, 2020 jwilliam 3.9k points
0 votes
1 answer 35 views
35 views
Problem: Hello Kodlogs, I tried pushing my app and I got an error message of this nature; you must use bundler 2 or greater with this lockfile. What can I do to correct this?
asked Nov 2, 2020 Festus James 360 points
0 votes
1 answer 287 views
287 views
Problem : I want to delete the uploaded image files with the AWS-SDK-Core Ruby Gem. I have the below code: require 'aws-sdk-core' def pull_picture(picture) Aws.config = { :access_key_id => ENV["AWS_ACCESS_KEY_ID"], :secret_access_key => ENV["AWS_SECRET_ACCESS_KEY"], :region => ... it to us-east-1, the below error comes up: The specified key does not exist. May I know how can I resolve this issue?
asked Dec 4, 2019 alecxe 7.5k points
0 votes
1 answer 243 views
243 views
Problem: I am very new to boto3. Now I have a boto3 client also: boto3.client('kms') But it always happens on all of my new machines they open and close dynamically. if endpoint is None:         if region_name is None:             # Raise a more specific error ... : Botocore.exceptions.noregionerror: you must specify a region. I want to know the reason behind this error and how can I fix it?
asked Aug 10, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 55 views
55 views
Problem : I am using two different third party programs those apparently use the Google Maps Javascript API. When they load the map, the world map is shown, but an Error message is displayed as below: you are using a browser that is not supported by the google maps javascript api
asked Oct 19, 2019 peterlaw 6.9k points