2

I received the next error while sending the ListObjectRequest:

The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256

According to this answer, AmazonS3Config was updated in the following way:

var amazonS3Config = new AmazonS3Config
{
    SignatureVersion = "4",
    ServiceURL = bucketName,
    RegionEndpoint = RegionEndpoint.USEast1,
    SignatureMethod = SigningAlgorithm.HmacSHA256
};

var s3Client = new AmazonS3Client(accessKeyID, secretKey, amazonS3Config);

But I still receive this error. What have I missed here?

Thanks.

Community
  • 1
  • 1
oleg
  • 55
  • 2
  • 8
  • I am using Frankfurt and my code is exactly as yours which works. Just hazarding a guess... Maybe USEast1 supports SignatureVersion 3 or below only? – Imran Saeed Mar 09 '17 at 16:42
  • I tried to use different signature versions (4, 3, 2) to check if it works with anyone. But it fails. – oleg Mar 10 '17 at 12:02
  • Can you try Frankfurt. Same code works for.me on Frankfurt so ne reason it shouldn't work for you..otherwise there's more to this issue than we can see... – Imran Saeed Mar 10 '17 at 17:45

2 Answers2

1

Try to use the last version of amazonS3 sdk.I think ServiceUrl is not necessary when you know regionEndpoint, I used it with private cloud amazonS3 and When I do not know the Region Endpoint. I can retrieve the information from Amazon using the following code.

        var amazonS3Config = new AmazonS3Config();
        // region of FrankPurt is : RegionEndpoint.EUCentral1
        // according to amazonS3 Doc http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region
        amazonS3Config.RegionEndpoint = RegionEndpoint.USEast1;

        var s3Client = new AmazonS3Client("your access key", "your secret key", amazonS3Config);
         S3DirectoryInfo dir = new S3DirectoryInfo(s3Client, "your bucket name", "your folder path without bucket name");
        Console.WriteLine(dir.GetFiles().Count());
0

By Using this I am able to work in EU west 2 region

            AmazonS3Config config = new AmazonS3Config();
            config.SignatureVersion = "4";
            config.RegionEndpoint = Amazon.RegionEndpoint.GetBySystemName("eu-west-2");
            config.SignatureMethod = Amazon.Runtime.SigningAlgorithm.HmacSHA256;

region should