I am trying for simple image upload using cURL by passing the required headers that is requested by AWS but I'm getting the below error...
<Code>AccessDenied</Code><Message>AWS authentication requires a valid Date or x-amz-date header</Message>
Below is the authorization header I'm passing in..
curl -X PUT -T "/some/file.jpg" \
-H "Host: bucket.s3.amazonaws.com" \
-H "Date: date" \
-H "Content-Type: image/jpg" \
-H "Authorization: AWS XXXXXXX:XXXXXXXXXX" \
https://bucket.s3.amazonaws.com/
and below is how the signature is made,
signature=`echo -en ${stringToSign} | openssl sha1 -hmac ${s3Secret} -binary | base64`
I've tried passing the date in stringToSign and in the headers, but no luck.. Please help ..
X-Amz-DateThe date that is used to create the signature. The format must be ISO 8601 basic format (YYYYMMDD'T'HHMMSS'Z'). For example, the following date time is a valid X-Amz-Date value: 20120325T120000Z .
In order to create an authorization header, you need an AWS Access Key Id and a Secret Access Key. In ECS, the AWS Access Key Id maps to the ECS user id (UID). An AWS Access Key ID has 20 characters (some S3 clients, such as the S3 Browser, check this), but ECS data service does not have this limitation.
AWS4-HMAC-SHA256. The algorithm that was used to calculate the signature. You must provide this value when you use AWS Signature Version 4 for authentication.
Fixed the issue.. Turns out the HTTP header need to be in RFC 7231 format. I formatted it and it worked., below is the format I used,
date -jnu +%a,\ %d\ %h\ %Y\ %T\ %Z
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With