Question

I am following the official Amazon S3 REST API documentation here and am having problems computing the same authorization values they show in their examples. The base64 HMAC-SHA1 hash they show for the first example is:

xXjDGYUmKxnwqr5KXNPGldn5LbA=

But I keep coming up with:

bWq2s1WEIj+Ydj0vQ697zp+IXMU=

I am tearing my hair out here. What can I possibly be doing wrong?

From their very first example:

static string TestS3(string key, string request) 
{
  var hash = new HMACSHA1(Encoding.UTF8.GetBytes(key));
  var data = hash.ComputeHash(Encoding.UTF8.GetBytes(request));
  return Convert.ToBase64String(data);
}

static void Main(string[] args)
{
  string key = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY";
  string request = "GET\n\n\nTue, 27 Mar 2007 19:36:42 +0000\n/johnsmith/photos/puppy.jpg";         
  Console.Write(TestS3(key, request));
}
Was it helpful?

Solution

Okay I found the problem. The keys used in the examples are wrong.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top