我正在浏览doc
以下代码解释了授权标头的构造:
Authorization = "AWS" + " " + AWSAccessKeyId + ":" + Signature;
Signature = Base64( HMAC-SHA1( YourSecretAccessKeyID, UTF-8-Encoding-Of( StringToSign ) ) );
StringToSign = HTTP-Verb + "\n" +
Content-MD5 + "\n" +
Content-Type + "\n" +
Date + "\n" +
CanonicalizedAmzHeaders +
CanonicalizedResource;
CanonicalizedResource = [ "/" + Bucket ] +
<HTTP-Request-URI, from the protocol name up to the query string> +
[ subresource, if present. For example "?acl", "?location", "?logging", or "?torrent"];
CanonicalizedAmzHeaders = <described below>
并且,在身份验证示例(例如OBJECT GET)中,他们显示StringToSign
,如下所示:
GET\n
\n
\n
Tue, 27 Mar 2007 19:36:42 +0000\n
/johnsmith/photos/puppy.jpg
我的问题:
为什么他们在\n
之后使用了三个GET
?这背后有原因吗?
另外,我可以按如下方式编写上述代码:
GET\n
\n
\n
Tue, 27 Mar 2007 19:36:42 GMT\n
答案 0 :(得分:1)
将“\ n”视为分隔符。由于示例是发送空Content-MD5
和Content-Type
,您会在一行中看到三个\n
。
我不确切知道您要做什么,但请记住,AWS软件开发工具包可以处理请求签名,因此您不必这样做。