AWS STS- httpwebrequest的SignaturedoesnotMatch错误,但在Postman和Python中完全相同的签名作品

发布于 2025-01-25 03:59:03 字数 615 浏览 0 评论 0原文

由于我们的系统复杂性,我们选择遵循计算AWS API签名的艰难方式,而不是使用AWS SDK。下面,向亚马逊STS发送请求以担任角色的3种不同方法。

  1. 首先,我使用Postman模拟了请求,并得到了所需的响应。
  2. 之后,我使用了AWS文档中的Python脚本来计算签名并发送请求。它也成功了。
  3. 最后,使用相同的AMZ日期和相同的凭证通过VB.NET脚本计算签名,在发送请求后,我遇到了此signaturedoesnotmatch错误(httpwebrequest)。

我可以看到,如果我使用特定的dateTime,则Python脚本和.NET中计算出的签名完全相同!但是,当我从Python请求发送它时,它可以正常运行时,当我从.NET httpwebrequest发送它时,它会失败。当我从Python发送并从.NET发送时,Amazon会计算不同的签名。

我猜想,某些标题被添加到我的.NET请求中,亚马逊使用并计算了与我的签名不同的签名?还有其他想法吗?

do notmatchSignatureerror

Due to our system complexity, we chose to follow the hard way of calculating the signature for AWS API instead of using AWS SDK. Below, 3 different ways for sending a request to Amazon STS to assume a role.

  1. First, I used Postman to simulate the request and I got the desired response.
  2. After that, i used the Python script from the AWS Docs to calculate the signature and send the request. It also succeeded.
  3. Finally, using the same Amz-Date and same credentials to calculate the signature through a VB.NET script, i got this SignatureDoesNotMatch error after sending the request ( HttpWebRequest ).

I can see that the calculated signatures in Python Script and .NET are exactly the same if I use a specific datetime! But when I send it from python requests it works, when I send it from .NET HttpWebRequest it fails. Amazon calculates a different signature when I send it from Python and when I send it from .NET .

I guess that some headers are added to my .NET request that Amazon uses and calculates a different signature than mine? Any other idea?

DoesNotMatchSignatureError

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文