I am getting following error while trying to upload to s3. The script below seems to be correct but still I get above error. Please can someone help me in solving this error. My secret key and access ID are correct as I am able to connect to AWS using these keys in java and ruby.
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message><AWSAccessKeyId>AKIAJNODAIRHFUX3LHFQ</AWSAccessKeyId><StringToSign>PUT
application/x-compressed-tar
Sun, 20 Dec 2015 19:54:47 -0500
/test-pk-proj//home/rushi/pk.tar.gz</StringToSign><SignatureProvided>M1PcN+Umkq5WFtVVSerHRGNABb8=</SignatureProvided><StringToSignBytes>50 55 54 0a 0a 61 70 70 6c 69 63 61 74 69 6f 6e 2f 78 2d 63 6f 6d 70 72 65 73 73 65 64 2d 74 61 72 0a 53 75 6e 2c 20 32 30 20 44 65 63 20 32 30 31 35 20 31 39 3a 35 34 3a 34 37 20 2d 30 35 30 30 0a 2f 74 65 73 74 2d 70 6b 2d 70 72 6f 6a 2f 2f 68 6f 6d 65 2f 72 75 73 68 69 2f 70 6b 2e 74 61 72 2e 67 7a</StringToSignBytes><RequestId>5439C7C84533E7C6</RequestId><HostId>620896ul+wnRwCjWl1ZtNZQ5NEJMGl29FqESC3iJyvnWhYhOECLlPl0417RfF3eovKFb7ac2.amazonaws.com port 443: Connection timed out
Below is my shell script which I am using to upload data to s3
file=/home/rushi/1.pdf
bucket=xxxxxxxxxxxxxxxxxxx
resource="/${bucket}/${file}"
contentType="application/x-compressed-tar"
dateValue=`date -R`
stringToSign="PUT\n\n${contentType}\n${dateValue}\n${resource}"
s3Key=xxxxxxxxxxxxxxxxxxxxxxxxxxx
s3Secret=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
signature=`echo -en ${stringToSign} | openssl sha1 -hmac ${s3Secret} -binary | base64`
curl -L -X PUT -T "${file}" \
-H "Host: ${bucket}.s3-website-us-west-2.amazonaws.com" \
-H "Date: ${dateValue}" \
-H "Content-Type: ${contentType}" \
-H "Authorization: AWS ${s3Key}:${signature}" \
https://${bucket}.s3-website-us-west-2.amazonaws.com/${file}