The MAC signature found in the HTTP request '…' is not the same as any computed signature

前端 未结 2 1268
孤独总比滥情好
孤独总比滥情好 2020-12-31 05:54

I\'m sending the following request in Postman to retrieve a simple .jpg from Azure Blob storage at this URL https://steamo.blob.core.windows.net/testcontainer/dog.jpg

<
相关标签:
2条回答
  • 2020-12-31 06:32

    Authentication for Azure Storage is not simply a matter of providing the access key (that is not very secure). You need to create a signature string that represents the given request, sign the string with the HMAC-SHA256 algorithm (using your storage key to sign), and encode the result in base 64. See https://msdn.microsoft.com/en-us/library/azure/dd179428.aspx for full details, including how to construct the signature string.

    0 讨论(0)
  • 2020-12-31 06:46

    Just got this working, here's 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);
    }
    
    0 讨论(0)
提交回复
热议问题