Artificial intelligent assistant

S3 head object but signature does not match I want to use curl to head objects in s3. code: s3key=xxxxx... (s3 key) s3skey=xxxxxx...(secret key) bucket=xxx file=/xx.txt date=$(date +"%a, %d %b %Y %T %z") string="HEAD\n\n\n$date\n/$bucket$file" signature=$(/bin/echo -en $string | openssl sha1 -hmac $s3skey -binary | base64) curl -H "Host: $bucket.s3.amazonaws.com" \ -H "Date: $date" \ -H "Authorization: AWS $s3key:$signature" \ it always shows request signature we calculate does not match the signature you provided. I dont know why? If I change to GET from HEAD , it will work and I got the objects. I don't understand which part of signature is wrong thx

The signature, as you realize, includes the http method (e.g. `GET`, `HEAD`) that the request will be using... but the signing process is a one-way process (using an HMAC digest), so the recipient of the signature (S3) has no way of knowing what parameters you used when signing the request -- it only knows that, based on the request you are making, the signature you provided doesn't match it.

The problem here is that you are creating a signature for a `HEAD` request, but curl is still _making_ a `GET` request. You can see this yourself by using `curl -v`.

The solution is to tell curl to actually make a `HEAD` request, and this is done with `curl -I`.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 0f2edcb4748a8d583595130bd6499a77