Re: [gs-discussion] Re: Query String Authentication - Constructing the String to be Signed

240 views
Skip to first unread message

Ville Aikas

unread,
Feb 21, 2013, 12:48:00 PM2/21/13
to gs-dis...@googlegroups.com
Shouldn't there be a \n after Expiration ($ttl) in the $stringToSign as per:
https://developers.google.com/storage/docs/accesscontrol#Signed-URLs

You can see the StringToSign we were expecting on the server side (in
the error message) and it has a newline between the Expiration and
CanonicalizedResource.

Ville...

On Thu, Feb 21, 2013 at 4:59 AM, Hayssen <hayssen...@gmail.com> wrote:
>> I add some details about my problem, this is my php code:
>
>
> ############
>
> $serviceAccountName = 'xxxCLIENT_ID_MAILxxx';
> $privateKey = file_get_contents($KEY_FILE_PATH);
> $signer = new Google_P12Signer($privateKey, 'xxx');
>
> $ttl = time() + 3600;
> $stringToSign = "GET\n" + "\n" + "\n" + $ttl + "/symfony/profil.png";
>
> $signature = $signer->sign(utf8_encode($stringToSign));
> $finalSignature = Google_Utils::urlSafeB64Encode($signature);
> $host = "http://xxxbucketxxx.storage.googleapis.com";
>
> $url = $host. "/profil.png?GoogleAccessId=" . $serviceAccountName .
> "&Expires=" . $ttl . "&Signature=" . $finalSignature;
> print '<a href="' . $url . '" target="_blank">test</a>';
>
> ############ Result when i use generated url ###########
>
> <?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 Google secret key and signing method.</Message><StringToSign>GET
>
>
> 1361451469
> /symfony/profil.png</StringToSign></Error>
>
>
> ##########
>
>
> Any idea about the cause of that error ?
>
>
> thx
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Cloud Storage" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to gs-discussio...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Google Cloud Storage Team

unread,
Mar 13, 2013, 1:31:59 PM3/13/13
to gs-discussion
Hello,

Yes, we found a solution to Hayssen's issues.  I have written up some example code, which I need to revise slightly, but will publish in the next few days.  If you would like to share what you have directly with me, I'll tell you if I can spot any obvious issues. 

Best Regards,
Benson
Google Cloud Storage Team


On Wed, Mar 13, 2013 at 10:10 AM, <in...@haremo.de> wrote:
Hi, did you found a soulution? haveing the same problem
Reply all
Reply to author
Forward
0 new messages