Issue
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 ..
Solution
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
Answered By - avinoth