sta*_*rd7 12 rest azure-storage-blobs postman
我在邮递员中发送以下请求,以便从此网址的Azure Blob存储中检索一个简单的.jpg https://steamo.blob.core.windows.net/testcontainer/dog.jpg
GET /testcontainer/dog.jpg HTTP/1.1
Host: steamo.blob.core.windows.net
Authorization: SharedKey steamo:<my access key>
x-ms-date: Tue, 26 May 2015 17:35:00 GMT
x-ms-version: 2014-02-14
Cache-Control: no-cache
Postman-Token: b1134f8a-1a03-152c-2810-9cb351efb9ce
Run Code Online (Sandbox Code Playgroud)
如果您对Postman不熟悉它只是一个REST客户端 - 可能会忽略Postman-Token标头.
我的访问密钥是从Azure管理门户复制的.
我收到此错误:
Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. RequestId:2482503d-0001-0033-60da-9708ed000000 Time:2015-05-26T17:35:41.4577821Z
Run Code Online (Sandbox Code Playgroud)
有了这个AutheticationErrorDetail:
The MAC signature found in the HTTP request '<my access key>' is not the same as any computed signature. Server used following string to sign: 'GET x-ms-date:Tue, 26 May 2015 17:35:00 GMT x-ms-version:2014-02-14 /steamo/testcontainer/dog.jpg'.
Run Code Online (Sandbox Code Playgroud)
我该如何解决?如果您需要我的更多信息,请告诉我.
小智 10
Azure存储的身份验证不仅仅是提供访问密钥(不是很安全).您需要创建一个代表给定请求的签名字符串,使用HMAC-SHA256算法对该字符串进行签名(使用您的存储密钥进行签名),并将结果编码为base 64.请参阅https://msdn.microsoft.com/ en-us/library/azure/dd179428.aspx获取完整详细信息,包括如何构造签名字符串.
刚开始工作,这是我的代码:
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);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9746 次 |
| 最近记录: |