SignatureDoesNotMatch - Amazon S3 API

I use the PHP class for Amazon S3 and CloudFront - Link . But when I try to upload the file to the bucket, I get this error:

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

How to fix it?

Thanks.

+7
source share
3 answers

When you sign up for Amazon, you can create a key pair for yourself (Amazon calls them a passkey and a secret passkey).

These two are used to sign requests to Amazon web services. Amazon recalculates the signature and compares it if it matches the one contained in your request. Thus, the secret access key should never be transmitted over the network.

If you get "Signature does not match", you are probably using the wrong secret passkey. Can you check the passkey and secret passkey to make sure they are correct?

+8
source

Personally, I got this error due to the characters that were in my metadata.

The problematic character was "-", which is "\ u2013" in Unicode and is different from "-".

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

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

Amazon S3 stores user metadata in lower case. Each name, pair value must match US-ASCII when using REST and UTF-8 when using SOAP or downloading through the browser via POST.

+4
source

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

0
source

All Articles