在从调用文件时,我试图在API头中创建一个有效的签名。作为回报,有一个错误:
/*I have rewritten all accounts and keys to fake*/
<Error>
<Code>AuthenticationFailed</Code>
<Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:aea05260-xxxx-xxxx-xxxx-xxxx58000000
Time:2022-06-30T03:26:24.1626176Z</Message>
<AuthenticationErrorDetail>The MAC signature found in the HTTP request 'ZmEyNjY0YmUwNWNjYmI2MmE1NTI2MDBjOGUyNTE2OTY0NmUzMjQ3NTU3Y2EwN2JhMmY3NmI5NmRiNDkxMzU2NA==
' is not the same as any computed signature. Server used following string to sign: 'GET
0
x-ms-date:Thu, 30 Jun 2022 03:24:00 GMT
x-ms-version:2014-02-14
/testgetfilestorage/integration/testfolder/abc123.xml'.</AuthenticationErrorDetail>
</Error>
我有Azure文件存储帐户& key,它可以在Microsoft Azure存储资源管理器上正常读取/下载文件,但我不确定创建签名时有什么问题,下面是如何在邮递员上测试REST API:
/*I have rewritten all accounts and keys to fake*/
On Postman:
URL:
GET https://testgetfilestorage.file.core.windows.net/integration/testfolder/abc123.xml
Header:
x-ms-version:2014-02-14
x-ms-date:Thu, 30 Jun 2022 03:24:00 GMT
Authorization:SharedKey testgetfilestorage:ZmEyNjY0YmUwNWNjYmI2MmE1NTI2MDBjOGUyNTE2OTY0NmUzMjQ3NTU3Y2EwN2JhMmY3NmI5NmRiNDkxMzU2NA==
根据Microsoft 授权共享密钥,我按照以下步骤创建签名:
/*I have rewritten all accounts and keys to fake*/
Signature=Base64(HMAC-SHA256(UTF8(StringToSign), Base64.decode(<your_azure_storage_account_shared_key>)))
/*My parameters as follow*/
StringToSign = 'GET\n\n\n0\n\n\n\n\n\n\n\n\nx-ms-date:Thu, 30 Jun 2022 03:24:00 GMT\nx-ms-version:2014-02-14\n/testgetfilestorage/integration/testfolder/abc123.xml'
your_azure_storage_account_shared_key = 'TRE/abcabcabcabc90+YCabcabcabcabcabcabcabcabcabcabcabcabcabcR2NC7i5WREgBAjNivlhwGhwmZQ=='
The steps I create the signature:
1. Signature=Base64(HMAC-SHA256(UTF8(GET\n\n\n0\n\n\n\n\n\n\n\n\nx-ms-date:Thu, 30 Jun 2022 03:24:00 GMT\nx-ms-version:2014-02-14\n/testgetfilestorage/integration/testfolder/abc123.xml), Base64.decode(TRE/abcabcabcabc90+YCabcabcabcabcabcabcabcabcabcabcabcabcabcR2NC7i5WREgBAjNivlhwGhwmZQ==)))
2. Signature=Base64(HMAC-SHA256(GET\n\n\n0\n\n\n\n\n\n\n\n\nx-ms-date:Thu, 30 Jun 2022 03:24:00 GMT\nx-ms-version:2014-02-14\n/testgetfilestorage/integration/testfolder/abc123.xml, M?i·mÆ›q¦Ü÷O˜ ¦Üi·mÆ›q¦Üi·mÆ›q¦Üi·mÆ›q¦ÜGcBî.VDH3b¾Xp&e))
3. Signature=Base64(fa2664be05ccbb62a552600c8e25169646e3247557ca07ba2f76b96db4913564)
4. Signature=ZmEyNjY0YmUwNWNjYmI2MmE1NTI2MDBjOGUyNTE2OTY0NmUzMjQ3NTU3Y2EwN2JhMmY3NmI5NmRiNDkxMzU2NA==
请告诉我在签名创作上做错了什么。
发布于 2022-07-06 15:18:07
https://stackoverflow.com/questions/72810548
复制相似问题