从以下位置获取错误消息https://mws.amazonservices.com/:
<Type>Sender</Type>
<Code>SignatureDoesNotMatch</Code>
−
<Message>
The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.
</Message>
这是我用来计算请求的 VB.net 代码。出于安全原因,我已删除 SecretKey 和 AWSAccessKeyId。
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim sURL As String = "https://mws.amazonservices.com/"
Dim sRequest As String = ""
sRequest &= "Acknowledged=" & Server.UrlEncode("false")
sRequest &= "&Action=" & Server.UrlEncode("GetReportList")
sRequest &= "&AWSAccessKeyId=" & Server.UrlEncode("REMOVED-FOR-SECURITY")
sRequest &= "&Marketplace=" & Server.UrlEncode("REMOVED-FOR-SECURITY")
sRequest &= "&Merchant=" & Server.UrlEncode("REMOVED-FOR-SECURITY")
sRequest &= "&SignatureMethod=" & Server.UrlEncode("HmacSHA256")
sRequest &= "&SignatureVersion=" & Server.UrlEncode("2")
sRequest &= "&Timestamp=" & Server.UrlEncode(DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ssCST"))
sRequest &= "&Version=" & Server.UrlEncode("2009-01-01")
Dim StringToSign As String = "GET\n" & "mws.amazonservices.com\n" & "/\n" & sRequest
sRequest &= "&Signature=" & Server.UrlEncode(HashString(StringToSign))
Response.Write("<a href=""" & sURL & "?" & sRequest & """>Click here</a>")
End Sub
Public Shared Function HashString(ByVal StringToHash As String) As String
Dim myEncoder As New System.Text.UTF8Encoding
Dim Key() As Byte = myEncoder.GetBytes("REMOVED-FOR-SECURITY")
Dim XML() As Byte = myEncoder.GetBytes(StringToHash)
Dim myHMACSHA256 As New System.Security.Cryptography.HMACSHA256(Key)
Dim HashCode As Byte() = myHMACSHA256.ComputeHash(XML)
Return Convert.ToBase64String(HashCode)
End Function
如果您在开始阅读一些 Amazon 文档后从 Google 登陆这里,那么您很可能会看到上面的“请求签名”错误,这是由于您的秘密访问密钥上无意中出现的前导或尾随空格所致。首先检查一下!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)