SignatureDoesNotMatch - Amazon S3 API

为君一笑 提交于 2019-12-22 04:27:10

问题


I am using a PHP class for Amazon S3 and CloudFront - Link. But when I try to upload a file into a bucket, I get this error:

[SignatureDoesNotMatch] The request signature we calculated does not match the signature you provided. Check your key and signing method.

How to fix it?

Thanks.


回答1:


When you sign up for Amazon, you can create yourself a key pair (Amazon calls those access key ID and secret access key).

Those two are used to sign requests to Amazon's webservices. Amazon re-calculates the signature and compares if it matches the one that was contained in your request. That way the secret access key never needs to be transmitted over the network.

If you get "Signature does not match", it's highly likely you used a wrong secret access key. Can you double-check access key and secret access key to make sure they're correct?




回答2:


Personally I received this error because of the characters that were in my meta data.

The problematic character was the "–" chracter which is "\u2013" in unicode and different to "-".

$result = $s3->putObject(array(
    'Bucket'       => $bucket,
    'Key'          => $keyname,
    'Metadata' => [
        'name' => 'Terminology – Blah'
    ]
));

A note from the documentation http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#UserMetadata...

Amazon S3 stores user-defined metadata in lowercase. Each name, value pair must conform to US-ASCII when using REST and UTF-8 when using SOAP or browser-based uploads via POST.




回答3:


I had this error with putObject() when specifying a Key starting with slash character (/) - after removing the slash it worked fine.



来源:https://stackoverflow.com/questions/10281557/signaturedoesnotmatch-amazon-s3-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!