Reputation: 430
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 ..
Upvotes: 6
Views: 17692
Reputation: 990
had similar issue but got:
Date must be in ISO-8601 'basic format'
which I used this to fix:
$(date -u +"%Y-%m-%dT%H:%M:%S%z")
Upvotes: 1
Reputation: 430
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
Upvotes: 5