1

the url generated from the method is different when compared with presigned url from aws console

from c# method https://bucket.s3.amazonaws.com/key?AWSAccessKeyId=xxxxxx&Expires=1642609317&Signature=xxxxx

c# link not working

from AWS Console:

https://bucket.s3.ap-south-1.amazonaws.com/key?response-content-disposition=inline&X-Amz-Security-Token=xxx&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20220119T154450Z&X-Amz-SignedHeaders=host&X-Amz-Expires=60&X-Amz-Credential=xxxxxx&X-Amz-Signature=xxxxxxxxx

package versions using

<PackageReference Include="AWSSDK.Core" Version="3.7.6" />
<PackageReference Include="AWSSDK.S3" Version="3.7.7.14" />

in the package available algorithms

namespace Amazon.Runtime
{
    //
    // Summary:
    //     The valid hashing algorithm supported by the sdk for request signing.
    public enum SigningAlgorithm
    {
        HmacSHA1 = 0,
        HmacSHA256 = 1
    }
}
Vman
  • 401
  • 1
  • 4
  • 14
  • Do you have a question? The C# SDK is using AWS4-HMAC-SHA256, is that a problem? – Anon Coward Jan 19 '22 at 16:47
  • @AnonCoward, I am trying to generate a presigned url from C# code, when accessed it, showing error to use this AWS4-HMAC-SHA256 for signature. with the latest AWS sdk I couldn't find that algorithm. Then I tried to generate from console, the link generated is different when compared with SDK. I would like to create presigned link from AWS SDK that works – Vman Jan 20 '22 at 08:09
  • You want to use "HmacSHA256" then. – Anon Coward Jan 20 '22 at 15:53
  • @Vman did you figure it out? I have a similar issue - C# client, 2 environments, same code. One generates a AWS4-HMAC-SHA256 and works, the other does not and fails – Andy Joiner Jan 25 '23 at 13:43

1 Answers1

0

A co-worker saw this issue 4 years ago only in us-east-1 on another project and put in the fix below. I plan to do the same.

Amazon.AWS.ConfigS3.UserSignatureVersion4 = true;
Andy Joiner
  • 5,932
  • 3
  • 45
  • 72