Amazon S3 Python S3Boto 403 Forbidden when the signature has a + sign

I use Django and S3Boto , and whenever the signature has a '+' sign, I get a 403 Forbidden . If there is no '+' sign in the signature, I get the resource just fine. What could be wrong here?

UPDATE:

Repo: https://github.com/boto/boto

relevant files:

 boto/utils.py boto/s3/connection.py 

Note: I am new to Python. I tried to change the code, but I still cannot correctly encode.

+6
source share
3 answers

In a nutshell, the problem is not in S3Boto, but in some invocation of "unquote", which occurs later on the url.

I answered a similar question:

Inconsistent SignatureDoesNotMatch Amazon S3 with django pipeline, s3boto and repositories

Please check my solution.

+1
source

I have a little short time (since it's 1:30 in the morning), so unfortunately I do not have a sample code yet, but I believe that this is because the + value in the URL should be encoded. So from github, your url ...

 https://s3.amazonaws.com/dragonflysco/static/js/plugins/blockui.js?Signature=+tahbTacs5Vkzt5jQ+hZULzGPhE=&Expires=1345019173&AWSAccessKeyId=AKIAJNCPYIZVZXKOPCHA 

really should be

 https://s3.amazonaws.com/dragonflysco/static/js/plugins/blockui.js?Signature=%2BtahbTacs5Vkzt5jQ+hZULzGPhE=&Expires=1345019173&AWSAccessKeyId=AKIAJNCPYIZVZXKOPCHA 

(Note: I replaced + with% 2B)

See http://www.w3schools.com/tags/ref_urlencode.asp

To fix the code, I would add the URLEncoding function, where it builds the URL query string.

+3
source

I just did what I hope will be fixing this problem in boto. See https://github.com/boto/boto/commit/a01a5d1a1e88f79ed5db52639d3674d9eb5e45dc . Please let me know if this takes care of the problem.

0
source

Source: https://habr.com/ru/post/923122/


All Articles