flexera-public / right_aws

RightScale Amazon Web Services Ruby Gems
MIT License
451 stars 175 forks source link

SignatureDoesNotMatch on file download via get_link() #109

Closed rbroemeling closed 12 years ago

rbroemeling commented 12 years ago

A link generated using response_params on RightAws 3.0.0 results in a SignatureDoesNotMatch response ("The request signature we calculated does not match the signature you provided. Check your key and signing method.") from Amazon S3.

I've traced this back to a line of code added in the generate_link method of lib/s3/right_s3_interface.rb, specifically:

def generate_link(method, headers={}, expires=nil) #:nodoc: .. path_to_sign = CGI.unescape(path_to_sign) ..

With this path_to_sign line commented OUT, the download proceeds normally and succeeds.

With this path_to_sign left alone (i.e. present in the code), the download fails with SignatureDoesNotMatch.

This line was added in:

https://github.com/rightscale/right_aws/commit/90d174b6c779c58644e074806bf717934dc906af

As the author of the original branch that was pulled in, though, I do not know why this unescape() was added. It was never in my branch (which works), and it's addition breaks file downloads if the filename contains a space.

Thanks.

rbroemeling commented 12 years ago

Note that this issue is related to https://github.com/rightscale/right_aws/pull/108 ; and might be resolved by that pull request.

This bit us pretty hard in a production environment today, would be great to have the fix released sooner rather than later.

konstantin-dzreev commented 12 years ago

Hi

I guess it was added in https://github.com/officedrop/right_aws/commit/f15f888be14bfa127e42434402078822643dee74 (right_s3_interface.rb line 858)

I've just committed couple fixes into master branch and bumped up the version to 3.0.1

Plz check if it works as expected

Thank you.

rbroemeling commented 12 years ago

I can confirm that git ref 52ad779aa7a7422bfb535da63cf5e6afe39149c4 works as we expect it to for files with spaces in their names, at least on our staging environment.

konstantin-dzreev commented 12 years ago

Thank you