0

I am adding an object to a bucket in Amazon S3. The addition is successful, now I want to make the file accessible to others by the pre-signed url.

The pre-signed url is of the form: https://<bucket>.s3.amazonaws.com/<key>?AWSAccessKeyId=<access key>&Expires=1432722343&Signature=mmfv%2Fddhhakla1csUrb%2FtRCXYu8%3D

But when I try to load the url, it return with an error:

    <Error>
<Code>SignatureDoesNotMatch</Code>
<Message>
         The request signature we calculated does not match the signature you provided. Check your key and signing method.
</Message>
<AWSAccessKeyId></AWSAccessKeyId>
<StringToSign>
      GET 1432727995 /<bucket>/<key>
</StringToSign>
<SignatureProvided>mmfv/ddhhakla1csUrb/tRCXYu8=</SignatureProvided>
<StringToSignBytes>
     47 45 54 0a 0a 0a 31 34 33 32 37 32 37 39 39 35 0a 2f 72 69 2d 73 65 72 76 69 63 65 2d 74 72 61 6b 2d 74 65 73 74 2f 74 65 73 74 53 75 6e 69 74 31 2e 78 6d 6c
</StringToSignBytes>
<RequestId>0E72b9858758353A0D906</RequestId>
<HostId>
    SOME VALUE
</HostId>
</Error>

Another Question: If I have an URI that has '+' in it, how do I access the page using the URI because trying the URI in the web browser turns it into space(" ") and that isn't correct?

tinus91
  • 247
  • 1
  • 6
  • 22
  • For the uri "+" part of your question it is normal. See https://stackoverflow.com/questions/5442658/spaces-in-urls – Finch_Powers May 27 '15 at 14:42
  • If a URL needs to represent a literal `+` it should be encoded as `%2B`. A space, in turn, is encoded as `%20`. On the signed URL, you aren't reusing the `PUT` URL to try to `GET` the object are you? What code is doing the signing? One of the SDKs? – Michael - sqlbot May 28 '15 at 01:31
  • @Michael-sqlbot The url that is generated as the pre-signed url , I am trying to use that uri to access the file, where it gives me an error of signature not matching. – tinus91 May 28 '15 at 09:07
  • Are you calculating the signature yourself, using the Secret Key associated with the Access Key in the URL? – John Rotenstein May 28 '15 at 10:58
  • @JohnRotenstein The pre-signed url is auto-generated, that contains the 'signature' param – tinus91 May 28 '15 at 12:10
  • Well, in that case it seems that the auto-generated signature is wrong. See: https://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html – John Rotenstein May 28 '15 at 20:25

0 Answers0