亚马逊MWS - 请求签名计算不提供匹配签名 [英] Amazon MWS - request signature calculated does not match the signature provided

查看:933
本文介绍了亚马逊MWS - 请求签名计算不提供匹配签名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

https://mws.amazonservices.com/ 得到以下错误消息:

 <类型>发件人< /型号>
< code取代; SignatureDoesNotMatch< / code取代;
 - 
<消息>
我们计算请求签名不您提供的签名相匹配。请检查您的AWS访问密钥和签名方法。咨询服务文档的详细信息。
< /消息>
 

下面是VB.net code我使用来计算的要求。我已删除了SecretKey的和AWSAccessKeyId出于安全原因。

 保护小组的Page_Load(BYVAL发件人为对象,BYVALË作为System.EventArgs)把手Me.Load
        昏暗SURL作为字符串=htt​​ps://mws.amazonservices.com/

        昏暗sRequest作为字符串=
        sRequest和放大器; =已确认=&放大器; Server.UrlEn code(假)
        sRequest和放大器; =&放大器;行动=&放大器; Server.UrlEn code(GetReportList)
        sRequest&安培; =与& AWSAccessKeyId =与& Server.UrlEn code(去掉-FOR-SECURITY)
        sRequest和放大器; =&放大器;卖场=&放大器; Server.UrlEn code(去掉-FOR-SECURITY)
        sRequest&安培; =与&商户=与& Server.UrlEn code(去掉-FOR-SECURITY)
        sRequest&安培; =与&是SignatureMethod =与& Server.UrlEn code(HmacSHA256)
        sRequest&安培; =与& SignatureVersion =与& Server.UrlEn code(2)
        sRequest&安培; =与&时间戳=与& Server.UrlEn code(DateTime.Now.ToString(YYYY-MM-DDTHH:MM:ssCST))
        sRequest和放大器; =&放大器;版本=&放大器; Server.UrlEn code(2009-01-01)

        昏暗StringToSign作为字符串=GET \ N&放大器; mws.amazonservices.com \ N&放大器; / \ N&放大器; sRequest
        sRequest&安培; =与&签名=与& Server.UrlEn code(HashString(StringToSign))

        回复于(< A HREF =&放大器; SURL和放大器;&AMP?; sRequest和放大器;>点击此处< / A>中)

    结束小组

    公共共享功能HashString(BYVAL StringToHash作为字符串)作为字符串
        昏暗的myEn codeR作为新System.Text.UTF8Encoding
        昏暗的密钥()作为字节= myEn coder.GetBytes(去掉-FOR-SECURITY)
        昏暗的XML()作为字节= myEn coder.GetBytes(StringToHash)
        昏暗myHMACSHA256作为新System.Security.Cryptography.HMACSHA256(钥匙)
        昏暗的哈希code以字节()= myHMACSHA256.ComputeHash(XML)
        返回Convert.ToBase64String(哈希code)
    端功能
 

解决方案

如果您是从谷歌登陆这里开始工作,通过一些亚马逊的文档后,它很可能是你看到上面的要求签名错误由于对你的秘密访问密钥无意前导或尾随空格。检查第一!

Getting the following error message from 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>

Here is the VB.net code I am using to calculate the request. I have removed the SecretKey and AWSAccessKeyId for security reasons.

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

解决方案

If you are landing here from Google after starting to work through some of the Amazon documentation, it's quite likely that you're seeing the 'request signature' error above due to a inadvertent leading or trailing space on your secret access key. Check that first!

这篇关于亚马逊MWS - 请求签名计算不提供匹配签名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆