Closed smartinec closed 12 years ago
Are you only getting signature errors when using UTF-8 headers? Do UTF-8 object names still work for you?
I'm not sure exactly what you mean by UTF-8 object names. The 'keyword' header is always encoded as UTF-8 as is the actual content stored in S3 (search engine result page). Here is an example page we are trying to store that had a failure:
We set Content-Type to what is returned by the engine. In this case "text/html; charset=UTF-8". We also set Content-Encoding to "gzip" since we use "gzencode()" on the response.
code for reproduce
S3::setAuth('XXX', 'XXX'); S3::setExceptions(true); $put = S3::putObject( S3::inputFile('1.txt'), 'your_bucket', '1.txt', S3::ACL_PUBLIC_READ, array( // Custom meta headers ), array( // Custom $requestHeaders "Cache-Control" => "max-age=315360000", "Expires" => gmdate("D, d M Y H:i:s T", strtotime("+5 years")), "Content-type" => "text/plain", ) ) var_dump($put);
Expected result bool(true)
Actual result Fatal error: Uncaught exception 'S3Exception' with message 'S3::putObject(): [SignatureDoesNotMatch] The request signature we calculated does not match the signa ture you provided. Check your key and signing method.' in S3.class.php:554
PUT /uploads/1.txt HTTP/1.1 User-Agent: S3/php Accept: / x-amz-acl: public-read Host: lingualeo_cdn.s3.amazonaws.com Date: Sat, 16 Jun 2012 15:21:58 GMT Content-MD5: aVSG6u6vFHNzw7+fh5KVCA== Content-Type: text/plain Cache-Control: max-age=315360000 Expires: Fri, 16 Jun 2017 15:21:58 GMT Content-type: text/plain Authorization: AWS AKIAJQPD6HCEUK55UXDQ:iac8pbUCyvYD2XhrnBwPEsb9K+o= Content-Length: 8 Expect: 100-continue
HTTP/1.1 403 Forbidden x-amz-request-id: 12631B4F2C527789 x-amz-id-2: pWcELTdRMhMpwLmzJY6aWppXRnqOWVJUJxVWB4ewOI6lDdmdQ9Kit/RgYiD1hscG Content-Type: application/xml Transfer-Encoding: chunked Date: Sat, 16 Jun 2012 15:22:10 GMT nnCoection: close Server: AmazonS3
41b <?xml version="1.0" encoding="UTF-8"?>
SignatureDoesNotMatch
0
Would you be able to try this patch? It seems like it is likely related to the meta header order.
https://github.com/codemedic/amazon-s3-php-class/commit/5e2d6f2772cc07ab0942e608bbda1569a5f4ddec
thanks! patch work fine... may be you merged this patch to main project repository?
The patch uses a lambda style function, it should ideally be a separate function for older PHP versions.
But I'm busy implementing it now, should push changes later today.
We are using S3 class version 0.4.0 and keep receiving the error below. We use a number of custom meta headers. The most likely culprit is our keyword header that is defined as:
'keyword' => mb_encode_mimeheader($keyword, 'UTF-8');
We seem to receive these errors when $keyword is Russian, Chinese, Japanese, etc.
User Warning: S3::putObject(): [SignatureDoesNotMatch] The request signature we calculated does not match the signature you provided. Check your key and signing method. in S3.php on line 358