Skip to content

S3 Presigned URL from EC2 not working while locally working

0

Hi, I have a webserver that write's to S3 and create a pre signed URL for the file to be downloaded, It is working locally. However, when I pushed it to EC2, the pre signed URL generated is not working. It throws the following error.

"The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256"

I haven't mentioned anywhere in my code the algorithm to be used. It is working perfectly locally and that drives me nuts.

2 Answers
3

Hi please check these steps also to help the resolve issue

Debugging Steps:

Verify Credentials: Double-check that your EC2 instance has the correct AWS credentials for S3 access. You can use the aws sts get-caller-identity command on the EC2 instance to verify its IAM role or environment variables.

Check SDK Versions: Use the pip show boto3 or equivalent command on both local and EC2 environments to confirm they have the same AWS SDK version. Update on EC2 if necessary.

**Review Code **Scrutinize your code for any discrepancies between local and EC2 environments, particularly around S3 client configuration and pre-signed URL generation.

Consider Logging: Add temporary logging statements to your code on the EC2 instance to capture the generated pre-signed URL and any relevant details about the signing process. This can help identify specific issues with the URL or signing mechanism.

EXPERT
answered 2 years ago
EXPERT
reviewed 2 years ago
EXPERT
reviewed 2 years ago
2

You need to use V4 signatures on your requests. There are some more info here.. Also ensure your using the latest S3 libary

https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingAWSSDK.html#specify-signature-version

EXPERT
answered 2 years ago
EXPERT
reviewed 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.