我用boto进行的第一次测试失败了SignatureDoesNotMatch

时间:2015-05-18 06:36:39

标签: amazon-s3 boto

所以这是我第一次使用boto测试S3存储桶:

import boto

user_name, access_key, secret_key = "testing-user", "xxxxxxxxxxxxx", "xxxxxxxx/xxxxxxxxxxxx/xxxxxxxxxx(xxxxx)"
conn = boto.connect_s3(access_key, secret_key)
buckets = conn.get_all_buckets()

我收到以下错误:

Traceback (most recent call last):
  File "test-s3.py", line 9, in <module>
    buckets = conn.get_all_buckets()
  File "xxxxxx/lib/python2.7/site-packages/boto/s3/connection.py", line 440, in get_all_buckets
    response.status, response.reason, body)
boto.exception.S3ResponseError: S3ResponseError: 403 Forbidden
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message><AWSAccessKeyId>AKIAJMHSZXU6MORWA5GA</AWSAccessKeyId><StringToSign>GET


Mon, 18 May 2015 06:21:58 GMT
/</StringToSign><SignatureProvided>c/+YJAZVInsfmd5giMQmrh81DPA=</SignatureProvided><StringToSignBytes>47 45 54 0a 0a 0a 4d 6f 6e 2c 20 31 38 20 4d 61 79 20 32 30 31 35 20 30 36 3a 32 31 3a 35 38 20 47 4d 54 0a 2f</StringToSignBytes><RequestId>5733F9C8926497E6</RequestId><HostId>FXPejeYuvZ+oV2DJLh7HBpryOh4Ve3Mmj8g8bKA2f/4dTWDHJiG8Bpir8EykLYYW1OJMhZorbIQ=</HostId></Error>

我该如何解决这个问题?

Boto版本是2.38.0

2 个答案:

答案 0 :(得分:1)

有同样的问题。就我而言,我生成的安全密钥有一个特殊字符&#39; +&#39;之间。所以我删除了我的密钥并重新生成了一个新密钥,它使用了新密钥而没有&#39; +&#39;。

Source

答案 1 :(得分:0)

今天,我在本地玩S3 API时看到了SignatureDoesNotMatch的错误响应,并用 127.0.0.1 替换 localhost 修复了我的问题。