jschneier / django-storages

https://django-storages.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
2.74k stars 859 forks source link

SignatureDoesNotMatch: The request signature we calculated does not match the signature you provided. Check your key and signing method. #782

Open orimboolak opened 4 years ago

orimboolak commented 4 years ago

Keep getting this error when i try to retrieve the saved image via url. Kindly help

DevMaxIT commented 4 years ago

Could you figure out a solution?

buddylindsey commented 4 years ago

I had this issue with a bucket in us-east-2. Without going into the last 2 hours of archeology of boto3 issues and storages code. I solved it by setting the following in my settings.py.

AWS_S3_ADDRESSING_STYLE = "virtual"

I am moving this chart up from below to help give more visibility to it.

Region Setting
us-east-1 default or AWS_S3_SIGNATURE_VERSION = "s3v4"
us-east-2 AWS_S3_ADDRESSING_STYLE = "virtual"
ap-northeast-1 AWS_S3_SIGNATURE_VERSION = "s3v4"
ap-southeast-2 AWS_S3_ADDRESSING_STYLE = "virtual"
ap-south-1 AWS_S3_ADDRESSING_STYLE = "virtual"
eu-central-1 AWS_S3_ADDRESSING_STYLE = "virtual"
eu-central-1 AWS_S3_ADDRESSING_STYLE = "virtual" AWS_S3_ENDPOINT_URL = 'https://s3.eu-central-1.amazonaws.com'
eu-west-1 AWS_S3_SIGNATURE_VERSION = "s3v4" AWS_S3_ADDRESSING_STYLE = "virtual"
eu-west-2 AWS_S3_ADDRESSING_STYLE = "virtual"
eu-west-3 AWS_S3_ADDRESSING_STYLE = "virtual"
ca-central-1 AWS_S3_ADDRESSING_STYLE = "virtual"

Based on a comment make sure you are up-to-date with the latest version of this package.

ghost commented 4 years ago

Spend 5 hours and this worked for me, @buddylindsey solution didn't worked for me AWS_DEFAULT_ACL = 'private' AWS_S3_SIGNATURE_VERSION = 's3v4'

buddylindsey commented 4 years ago

@AchintyaRanjanChaudhary what region where you in and version of boto3? I found those settings, but the version of boto3 I had was already using s3v4.

rozeweb commented 4 years ago

I had this issue with a bucket in us-east-2. Without going into the last 2 hours of archeology of boto3 issues and storages code. I solved it by setting the following in my settings.py.

AWS_S3_ADDRESSING_STYLE = "virtual"

Your a life saver!!! Thanks.

ghost commented 4 years ago

@buddylindsey boto version --> boto3==1.13.13 AWS region -->ap-northeast-1 django-storage --> django-storages==1.9.1

buddylindsey commented 4 years ago
So it looks like so far Region Setting
us-east-1 default or AWS_S3_SIGNATURE_VERSION = "s3v4"
us-east-2 AWS_S3_ADDRESSING_STYLE = "virtual"
ap-northeast-1 AWS_S3_SIGNATURE_VERSION = "s3v4"
eu-central-1 AWS_S3_ADDRESSING_STYLE = "virtual"
eu-west-2 AWS_S3_ADDRESSING_STYLE = "virtual"
eu-west-3 AWS_S3_ADDRESSING_STYLE = "virtual"

If we get more variations from people or other regions I can update this table.

ghost commented 4 years ago

I had this issue with a bucket in us-east-2. Without going into the last 2 hours of archeology of boto3 issues and storages code. I solved it by setting the following in my settings.py.

AWS_S3_ADDRESSING_STYLE = "virtual"

I love you.

hi-18-K commented 4 years ago

getting this error again and again..none of the above worked..but observed that url of file from website does not contain "Amz-Security-Token" field..how to resolve that?

krystofbe commented 4 years ago

AWS_S3_ADDRESSING_STYLE = "virtual" also works for eu-central-1

Psyborgs-git commented 4 years ago

I had this issue with a bucket in us-east-2. Without going into the last 2 hours of archeology of boto3 issues and storages code. I solved it by setting the following in my settings.py.


AWS_S3_ADDRESSING_STYLE = "virtual"

Dude! This Totally worked thanks.

aureliendebord commented 3 years ago

AWS_S3_ADDRESSING_STYLE = "virtual"

Also works for eu-west-3

davidysoards commented 3 years ago

Added a new, identical setting bucket in region us-east-2 for use in dev only, and had to add AWS_S3_ADDRESSING_STYLE = "virtual" thanks @buddylindsey 1st bucket worked without it, but also works with it. 🤷🏻‍♂️ The first bucket didn't work until I added AWS_S3_SIGNATURE_VERSION = "s3v4", but the new one works with or without it. Not sure if the 1st still needs AWS_S3_SIGNATURE_VERSION too, but I'm leaving it for now.

Is it django-storages causing all these inconsistencies or AWS?

gcmestre commented 3 years ago

First of all thank you. This answers really helped. Second: I have a bucket at us-east-1 and the default didn't work neither the WS_S3_ADDRESSING_STYLE = "virtual". What it worked was AWS_S3_SIGNATURE_VERSION = "s3v4"

dunderJB commented 3 years ago

I had this issue with a bucket in us-east-2. Without going into the last 2 hours of archeology of boto3 issues and storages code. I solved it by setting the following in my settings.py.

AWS_S3_ADDRESSING_STYLE = "virtual"

Dude i love you tks !!!

Vinay-Indoria commented 3 years ago

@buddylindsey Thanks alot

AWS_S3_ADDRESSING_STYLE = "virtual"

worked for us-east-2

adamcharnock commented 3 years ago

AWS_S3_ADDRESSING_STYLE = "virtual" worked for eu-west-2. Thank you! ♥️

shdigitalpy commented 3 years ago

Many thanks for this info. This saved me another hour of searching through code

vinodkr494 commented 3 years ago

AWS_S3_ADDRESSING_STYLE = "virtual" worked for eu-west-2. Thank You..

dinie commented 3 years ago
AWS_S3_ADDRESSING_STYLE = "virtual"

Works for ap-southeast-2. Thank you!

ZackPlauche commented 3 years ago

I tried all of these solutions for the correct timezones and for some reason it's still not working 🤦‍♂️ I've triple checked my keys and tried both:

AWS_S3_ADDRESSING_STYLE = "virtual"

and

AWS_S3_SIGNATURE_VERSION = "s3v4"

one at a time and even at the same time.

I made a new bucket under us-east-1 just because that's what was shown in other answers and it still didn't work with either settings.

Ram-95 commented 3 years ago

This works for the region - ap-south-1

AWS_S3_ADDRESSING_STYLE = "virtual"
CoolBytesIN commented 3 years ago

So it looks like so far Region Setting us-east-1 default or AWS_S3_SIGNATURE_VERSION = "s3v4" us-east-2 AWS_S3_ADDRESSING_STYLE = "virtual" ap-northeast-1 AWS_S3_SIGNATURE_VERSION = "s3v4" eu-central-1 AWS_S3_ADDRESSING_STYLE = "virtual" eu-west-2 AWS_S3_ADDRESSING_STYLE = "virtual" eu-west-3 AWS_S3_ADDRESSING_STYLE = "virtual"

If we get more variations from people or other regions I can update this table.

"virtual" setting works for ca-central-1 as well.

asdfractal commented 2 years ago

While troubleshooting student projects I have found that this is caused by there being a / in the secret access key. I didn't know about these settings but generating new credentials without the / would solve it.

radupm commented 2 years ago

This also works for eu-west-1:

AWS_S3_SIGNATURE_VERSION = "s3v4"
AWS_S3_ADDRESSING_STYLE = "virtual"
JMIdeaMaker commented 1 year ago

None of these worked for me. us-east-2

Edit: Updating from storages 1.9 to 1.13.1 fixed this error

milenmihaylov commented 1 year ago

I had this issue with a bucket in us-east-2. Without going into the last 2 hours of archeology of boto3 issues and storages code. I solved it by setting the following in my settings.py.

AWS_S3_ADDRESSING_STYLE = "virtual"

I am moving this chart up from below to help give more visibility to it.

Region Setting us-east-1 default or AWS_S3_SIGNATURE_VERSION = "s3v4" us-east-2 AWS_S3_ADDRESSING_STYLE = "virtual" ap-northeast-1 AWS_S3_SIGNATURE_VERSION = "s3v4" ap-southeast-2 AWS_S3_ADDRESSING_STYLE = "virtual" ap-south-1 AWS_S3_ADDRESSING_STYLE = "virtual" eu-central-1 AWS_S3_ADDRESSING_STYLE = "virtual" eu-central-1 AWS_S3_ADDRESSING_STYLE = "virtual" AWS_S3_ENDPOINT_URL = 'https://s3.eu-central-1.amazonaws.com' eu-west-1 AWS_S3_SIGNATURE_VERSION = "s3v4" AWS_S3_ADDRESSING_STYLE = "virtual" eu-west-2 AWS_S3_ADDRESSING_STYLE = "virtual" eu-west-3 AWS_S3_ADDRESSING_STYLE = "virtual" ca-central-1 AWS_S3_ADDRESSING_STYLE = "virtual" Based on a comment make sure you are up-to-date with the latest version of this package.

For eu-central-1 you need both settings as they are. Cheers buddy! You got a beer from me.

MarcinR1989 commented 1 year ago

For eu-central-1 I needed to set 3 mentioned before variables: AWS_S3_ADDRESSING_STYLE = "virtual" AWS_S3_ENDPOINT_URL = 'https://s3.eu-central-1.amazonaws.com' AWS_S3_ADDRESSING_STYLE = "virtual"

and also 1 additional: AWS_S3_REGION_NAME = 'eu-central-1'

Jackevansevo commented 11 months ago

Ran into this issue today and found both combinations work (for a public bucket)

AWS_S3_REGION_NAME = 'us-east-2'
AWS_S3_ENDPOINT_URL = f'https://s3.{AWS_S3_REGION_NAME}.amazonaws.com'

or

AWS_S3_REGION_NAME = 'us-east-2'
AWS_S3_ADDRESSING_STYLE = 'path'

along with my AWS_STORAGE_BUCKET_NAME

cornuel commented 10 months ago

Thank you @Jackevansevo, I tried AWS_S3_ADDRESSING_STYLE = 'virtual' and I still would get the SignatureDoesNotMatch error but it works with AWS_S3_ADDRESSING_STYLE = 'path', my bucket is hosted in eu-west-3 . It has the effect of changing the url from

https://{bucket_name}.s3.{region_name}.amazonaws.com

to

https://s3.{region_name}.amazonaws.com/{bucket_name}

If someone can tell me why this works and not the first url I would gladly appreciate. EDIT: I waited one night and now both addressing style works, I literally spent all yesterday afternoon debugging this. RIP

bonfimjustino7 commented 10 months ago

Hi guys, I uploaded my application to Vercel and it started pointing out this error. However, when running the local application or in an EC2 instance, it generates another url with less information and I can access the file without problems.

Anyone else going through this that has resolved it? My Region: us-east-1 My settings AWS_S3_ACCESS_KEY_ID = os.environ.get("AWS_S3_ACCESS_KEY_ID") AWS_S3_SECRET_ACCESS_KEY = os.environ.get("AWS_S3_SECRET_ACCESS_KEY") AWS_STORAGE_BUCKET_NAME = os.environ.get("AWS_STORAGE_BUCKET_NAME") AWS_S3_CUSTOM_DOMAIN = os.environ.get("AWS_S3_CUSTOM_DOMAIN") AWS_STORAGE_PRIVATE_BUCKET_NAME = os.environ.get("AWS_STORAGE_PRIVATE_BUCKET_NAME") AWS_DEFAULT_ACL = None AWS_S3_SIGNATURE_VERSION = "s3v4"

elinteerie commented 6 months ago
AWS_S3_ADDRESSING_STYLE = "virtual"

This also worked for me. thanks

smanish-hub commented 2 weeks ago

AWS_S3_ADDRESSING_STYLE = "virtual"

Thank you this works for me