我正在尝试签署一个亚马逊sts令牌请求,以便临时访问我的S3帐户。我一直在遵循签名版本4的说明,没有运气。
我不断从亚马逊sts收到这条消息。
<Code>IncompleteSignature</Code>
<Message>Request must contain a signature that conforms to AWS standards</Message>
以下是我发送的网址请求。
https://sts.amazonaws.com/?AWSAccessKeyId=**********&Action=GetFederationToken&DurationSeconds=3600&SignatureMethod=HmacSHA256&SignatureVersion=4&Timestamp=2013-04-23T19:01:00Z&Version=2011-06-15&Signature=2fc3dc902a20a5aa25c3191f2aa6513088e11596082b6a563b00dc5ea4b8bfa0
按照签名版本4的步骤,这是我计算签名的方式。
http://docs.aws.amazon.com/general/latest/gr/sigv4_signing.html
任务1:
GET\n
/\n
AWSAccessKeyId=<Access Key Removed>&
Action=GetFederationToken&
DurationSeconds=3600&
SignatureMethod=HmacSHA256&
SignatureVersion=4&
Timestamp=2013-04-23T19:01:00Z&
Version=2011-06-15\n
host:sts.amazonaws.com\n
host\n
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
任务2:
AWS4-HMAC-SHA256\n
20130423T190100Z\n
20130423/us-gov-west-1/sts/aws4_request\n
5e769aeb49a050fd7cd1035122712098fd83220ea42a0d9871f0ff2fa622b1c6
任务3:
Signature: 2fc3dc902a20a5aa25c3191f2aa6513088e11596082b6a563b00dc5ea4b8bfa0
任何帮助都会非常感激我到目前为止一直没有运气。在此先感谢:)
答案 0 :(得分:2)
在这里做笔记我终于能够通过改变我的请求获得一个令牌。如果这将有助于其他任何有同样问题的人。我无法在文档中找到太多帮助,但通过不断修改我的请求,我终于能够从服务器获得有用的错误消息。最重要的消息是最后一个消息,它准确地给出了请求签名和要签名的字符串应该是什么。
这特别适用于从Amazon Secure Token Service检索联合令牌。
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
/
Action=GetFederationToken&Version=2011-06-15&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAXXXXXXXXXWIQ%2F20130424%2Fus-east-1%2Fsts%2Faws4_request&X-Amz-Date=20130424T183200Z&X-Amz-SignedHeaders=host%3Bx-amz-date
host:sts.amazonaws.com
x-amz-date:
host;x-amz-date
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
The String-to-Sign should have been
'AWS4-HMAC-SHA256
20130424T183200Z
20130424/us-east-1/sts/aws4_request
3eb22aba7f25dd4e01be888added6f74db579bdf0d066d2b1f75779a25b1300d'
这是使用的网址。
https://sts.amazonaws.com/?Action=GetFederationToken&Name=Megan&Version=2011-06-15&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIXXXXXXXXXXWIQ%2F20130424%2Fus-east-1%2Fsts%2Faws4_request&X-Amz-Date=20130424T183200Z&X-Amz-SignedHeaders=host%3Bx-amz-date&X-Amz-Signature=db754013466768c11a86a610796faad6a041bcad9d83f4c958cac82988d2f7d7
答案 1 :(得分:1)
Amazon S3目前不支持签名版本4.有关当前支持的签名算法,请参阅S3文档:
http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html
编辑:很抱歉误读了您的初始请求。您对签名计算中导致问题的STS请求有许多不正确的假设:
虽然我了解您可能不想使用SDK,但他们会举例说明如何生成签名。
以下是我从iOS SDK中提取的示例。
Canonical Request:
POST\n
/\n
\n
host:sts.amazonaws.com\n
x-amz-date:20130424T164023Z\n
\n
host;x-amz-date\n
HASH_REMOVED\n
要签名的字符串:
AWS4-HMAC-SHA256\n
20130424T164023Z\n
20130424/us-east-1/sts/aws4_request\n
HASH_REMOVED