locked
The MAC signature found in the HTTP request 'xxxxxxxxxxxxxxxxxx' is not the same as any computed signature. Server used following string to sign: 'GET RRS feed

  • Question

  • Hi i am trying to get file from azure storage using storage access key using C# code to generate authorization key and i am getting following error. "The MAC signature found in the HTTP request 'xxxxxxxxxxxxxxxxxx' is not the same as any computed signature. Server used following string to sign: 'GET."

    Here is my code. 

    string signWithAccountKey(string stringToSign, string accountKey)
    {
        var hmacsha = new System.Security.Cryptography.HMACSHA256();
        hmacsha.Key = Convert.FromBase64String(accountKey);
        var signature = hmacsha.ComputeHash(Encoding.UTF8.GetBytes(stringToSign));
        return Convert.ToBase64String(signature);
    }

    My stringTOSign looks like 

    "GET\n\n\n\n\n\n
    x-ms-date:Wed, 26 Jun 2019 12:55:40 GMT\n/myaccount/mycontainer"

    I didn't find solution for my problem anywhere. Please help me in generating proper authorization signature. 

    My request header looks like 

    "Authorization": "SharedKey MyAccount:Signature"

    Wednesday, June 26, 2019 1:07 PM

All replies

  • Pradeep, For testing purposes, when generating the key from either Azure portal or Storage explorer, does it work ?
    Once the key is generated, it will be compared to the original when you would use it for an object. My guess is that when generating the key and hashing it, it doesn't checkout with the original key. I'd recommend testing the key generated directly from portal or Storage Explorer and giving it a shot, then doing the hashing and trying again.  this would narrow the causes and help find a solution. Let me know if this helps.
    Wednesday, June 26, 2019 5:15 PM
  • @Pradeep S S  Just checking in to see if the above answer helped. If this answers your query, do click “Mark as Answer” and Up-Vote for the same, which might be beneficial to other community members reading this thread. And, if you have any further query do let us know.
    Wednesday, July 10, 2019 6:44 AM