【问题标题】:Connecting to Azure via Postman通过 Postman 连接到 Azure
【发布时间】:2021-02-24 09:44:34
【问题描述】:

我们正在尝试通过邮递员连接到 Azure,但得到了

“在 HTTP 请求中找到的 MAC 签名与任何计算的签名不同”。我们根据文档所做的就是构造一个要签名的字符串:

GET\n\n\n\n\n\n\n\n\n\n\n\nx-ms-date:2021 年 2 月 24 日星期三 08:50:08 GMT\nx-ms-version :2020-04-08\n/myaccount/容器名/文件名

然后我们从base64解码accesskey

从那里我们使用在线工具使用 HMAC SHA256 和 Azure 门户的访问密钥加密签名。

请看照片: Azure SharedKey

我们使用它作为授权标头 SharedKey myaccount:HashedOutput 但是我们得到了这个错误: Error in Postman

有人可以就此提出建议吗?谢谢!

【问题讨论】:

    标签: azure postman


    【解决方案1】:

    如果您请求 Get Blob Rest API,则字符串签名是正确的。但是encode the signature 的步骤似乎不正确。

    要对签名进行编码,请调用 HMAC-SHA256 算法 UTF-8 编码的签名字符串并将结果编码为 Base64。笔记 您还需要对您的存储帐户密钥进行 Base64 解码。使用 以下格式(显示为伪代码):

    Signature=Base64(HMAC-SHA256(UTF8(StringToSign), Base64.decode(<your_azure_storage_account_shared_key>)))
    

    使用 PHP 对签名进行编码:

    $date = gmdate('D, d M Y H:i:s \G\M\T');
    $version = "2020-04-08";
    echo $date;
    
    $stringtosign = "GET\n\n\n\n\n\n\n\n\n\n\n\nx-ms-date:". $date . "\nx-ms-version:".$version."\n/".$storageAccount."/".$containerName."/".$blobName;
    $signature = 'SharedKey'.' '.$storageAccount.':'.base64_encode(hash_hmac('sha256', $stringtosign, base64_decode($account_key), true));
    echo "\n\n" . $signature;
    

    使用 Powershell 对签名进行编码:https://docs.microsoft.com/en-us/answers/questions/59066/create-authorization-header-with-shared-key-using.html

    【讨论】:

    猜你喜欢
    • 2020-05-26
    • 2019-12-14
    • 1970-01-01
    • 2021-11-16
    • 1970-01-01
    • 1970-01-01
    • 2012-12-05
    • 2020-07-30
    • 2016-02-18
    相关资源
    最近更新 更多