amazonwebservices / aws-sdk-for-php

(DEPRECATED) AWS SDK for PHP - Version 1. Version 3 is the latest:

Home Page:https://github.com/aws/aws-sdk-php

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SignatureDoesNotMatch Error

jspizziri opened this issue · comments

@jeremeamia , I am getting a SignatureDoesNotMatch response from Amazon. However, my keys are correct. I have tested the generated signature by generating one outside of the SDK for verification. I think the problem is here:

This is the string that is being used to generate the signature:

PUT
JtUx3diApbCp4pI5KQ4F/Q==
application/octet-stream
Fri, 25 Apr 2014 16:00:40 GMT
x-amz-acl:public-read
/myBucket/one.m4a

However, the amazon response contains two copies of the stringtosign. The first one is the same as above and is sent in the header. The second is sent in the body and looks like this:

PUT
JtUx3diApbCp4pI5KQ4F/Q==
application/octet-stream; boundary=----------------------------b98b484efce0
Fri, 25 Apr 2014 16:00:40 GMT
x-amz-acl:public-read
/myBucket/one.m4a

Where is this coming from?

; boundary=----------------------------b98b484efce0

I believe that amazon is checking the signature based on this stringtosign, which is why I'm receiving an invalid signature response.

P.S. I'm using Gaufrette (within a Symfony2 app).

I've never seen that before. @skyzyx have you ever seen that? Is the SDK working outside of Gaufrette? Have you tried using SDK 2? Gaufrette also supports SDK 2: https://github.com/KnpLabs/Gaufrette/blob/master/src/Gaufrette/Adapter/AwsS3.php.

I haven't tried the sdk outside of the context of Guafrette. I similarly filed an issue ( KnpLabs/Gaufrette#279) in that repo as initially I suspected it was Gaufrette.

I attempted using the SDK2 with Gaufrette but ran into some problems:

  [Aws\Common\Exception\InvalidArgumentException]                          
  The provided signature value is not an instance of S3SignatureInterface

which happened after I setup my yml config and cleared my cache... not sure where this was coming from. Don't know if you have any ideas, but there is no config provided by the GuafretteBundle to input a 'signature', so I'm not sure.

... sorry for rambling on, I've just been working on this for the last part of my week. I just want to get those freakin files in my S3 bucket, you know what I'm sayin?

I'll probably file an issue with GaufretteBundle.

Was a fix for this ever found? I have the same problem I believe. When I try running composer.phar update, I get

The contents of http://packagist.org/p/amazonwebservices/aws-sdk-for-
php$01f235aa53207f8604813b7d71d6089563c7faaf6f1332efc2fb019a8f1f979b.json do not match its 
signature. This should indicate a man-in-the-middle attack. Try running composer again and report 
this if you think it is a mistake.

My composer.json list of dependencies is

        "php": ">=5.3.3",
        "symfony/symfony": "2.6.*",
        "doctrine/orm": ">=2.2.3,<2.4-dev",
        "doctrine/doctrine-bundle": "1.0.*",
        "twig/extensions": "1.0.*",
        "symfony/assetic-bundle": "2.1.*",
        "symfony/swiftmailer-bundle": "2.1.*",
        "symfony/monolog-bundle": "2.1.*",
        "sensio/distribution-bundle": "2.1.*",
        "sensio/framework-extra-bundle": "2.1.*",
        "sensio/generator-bundle": "2.1.*",
        "jms/security-extra-bundle": "1.2.*",
        "jms/di-extra-bundle": "1.1.*",
        "friendsofsymfony/user-bundle": "*",
        "stof/doctrine-extensions-bundle": "1.1.x-dev",
        "knplabs/knp-snappy-bundle": "dev-master",
        "knplabs/knp-menu-bundle":">=1.1.0,<2.0.x-dev",
        "knplabs/knp-gaufrette-bundle": "0.2.*@dev",
        "twitter/bootstrap": "master",
        "friendsofsymfony/jsrouting-bundle": "1.1.*",
        "sonata-project/admin-bundle": "dev-master",
        "sonata-project/doctrine-orm-admin-bundle": "dev-master",
        "liip/imagine-bundle": "dev-master",
        "amazonwebservices/aws-sdk-for-php": "dev-master"

Can you check your mbstring override settings ?
I think it is because the the mbstring override the strlen function to mb_strlen(), which support multi byte charracters and thus mislead the algorithm in charge of building the signature.

@lasryaric I ended up following this suggestion and was able to get past this issue. :P