Kyl*_*ard 65 asp.net amazon-web-services
从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>
Run Code Online (Sandbox Code Playgroud)
这是我用来计算请求的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
Run Code Online (Sandbox Code Playgroud)
And*_*rew 142
如果您在开始处理某些亚马逊文档后从Google登陆此处,则很可能由于您的秘密访问密钥上无意中的前导或尾随空间而导致上述"请求签名"错误.先检查一下!
Nic*_*ers 25
根据我的经验,这个错误只是意味着"你的一个参数是错误的,祝你好运!" 我使用S3 SDK遇到了这个错误.我试图上传文件,但我错误地提供了完整的文件路径("C:\ Users\addaone\image.png")作为密钥,而不仅仅是文件名.
Joa*_*eme 19
解决方案是生成一个新的访问密钥.我的第一个AWSSecretKey在它上面有可能导致问题的正斜杠,而新的斜杠没有任何正斜杠并且工作正常.
Fio*_*ite 16
我发现这是因为我没有进行URL编码 - 如果传递的任何参数无效,则会返回此错误 - 它可能与访问密钥没有任何关系.