AWS 签名 URL 问题
AWS Signed URL issue
我尝试使用 Web 浏览器的 AWS 签名 v4 实施向带有签名的 AWS 发送请求。
我的请求是这样的:
GET /test?id=ID-12
我收到 403 错误消息,如:
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.
The Canonical String for this request should have been
'GET
/test
accept:*/*
...
所以,如您所见,这里没有参数,我认为这是问题所在,但我不明白的是,AWS 如何就应该是什么提出建议?我的意思是签名是由散列表示的,不是吗?或者我错过了什么?提前致谢!
稍微简化一下流程,AWS 使用 HMAC 生成签名。
关键原则之一是 HMAC 不加密消息。消息必须与 HMAC 散列一起发送。接收方将再次计算HMAC并验证结果。
AWS 在 Signature Documentation:
中明确讨论了这一点
When an AWS service receives the request, it performs the same steps that you did to calculate the signature you sent in your request. AWS then compares its calculated signature to the one you sent with the request. If the signatures match, the request is processed. If the signatures don't match, the request is denied.
回答您的明确问题:他们向您展示的用于生成 "Canonical String" 的字符串源自 HTTP 请求本身。第一行的 HTTP 类型 "GET",第二行传递给 GET 的路径,依此类推。
换句话说,他们希望调用者了解请求的样子,事先自己生成规范字符串,运行他们的签名算法和访问密钥的秘密的共享秘密,并在请求中包含生成的哈希值。然后他们从 HTTP 请求中获取元素,运行 再次执行此过程,并验证结果是否正确。
对于你的失败,如果你post你是如何生成预签名的URL,我们也许能够诊断出失败的地方。
我尝试使用 Web 浏览器的 AWS 签名 v4 实施向带有签名的 AWS 发送请求。
我的请求是这样的: GET /test?id=ID-12
我收到 403 错误消息,如:
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.
The Canonical String for this request should have been
'GET
/test
accept:*/*
...
所以,如您所见,这里没有参数,我认为这是问题所在,但我不明白的是,AWS 如何就应该是什么提出建议?我的意思是签名是由散列表示的,不是吗?或者我错过了什么?提前致谢!
稍微简化一下流程,AWS 使用 HMAC 生成签名。
关键原则之一是 HMAC 不加密消息。消息必须与 HMAC 散列一起发送。接收方将再次计算HMAC并验证结果。
AWS 在 Signature Documentation:
中明确讨论了这一点When an AWS service receives the request, it performs the same steps that you did to calculate the signature you sent in your request. AWS then compares its calculated signature to the one you sent with the request. If the signatures match, the request is processed. If the signatures don't match, the request is denied.
回答您的明确问题:他们向您展示的用于生成 "Canonical String" 的字符串源自 HTTP 请求本身。第一行的 HTTP 类型 "GET",第二行传递给 GET 的路径,依此类推。
换句话说,他们希望调用者了解请求的样子,事先自己生成规范字符串,运行他们的签名算法和访问密钥的秘密的共享秘密,并在请求中包含生成的哈希值。然后他们从 HTTP 请求中获取元素,运行 再次执行此过程,并验证结果是否正确。
对于你的失败,如果你post你是如何生成预签名的URL,我们也许能够诊断出失败的地方。