Imported Google Group message.
Sender:Martin Buhr
.
Date:Thursday, 12 February 2015 15:09:10 UTC.
I use URI::Escape to encode my url and it changes space in %20.
If I replace %20 by + it’s working !
The final script:
#!/bin/bash
function urlencode() {
echo -n “$1” | perl -MURI::Escape -ne ‘print uri_escape($_)’ | sed “s/%20/+/g”
}
date=“$(LC_ALL=C date -u +”%a, %d %b %Y %X %Z")"
encoded_date=urlencode "${date}"
signature=echo -n "date:${encoded_date}" | openssl sha1 -binary -hmac "MzBjODkwOTE1OTk1NDExYjUwNDNkOTk5N2FhMWQ4ZTY="|base64
url_encoded_signature=urlencode "${signature}"
echo “date: $date”
echo “encoded date: $encoded_date”
echo “signature: $signature”
echo “url_encoded_signature: $url_encoded_signature”
curl -H “Date: ${date}” -H “Authorization: Signature keyId="69011da4b26543d144c5a9ee4714fb6f",algorithm="hmac-sha1",signature="${url_encoded_signature}"” ‘http://localhost:8081/api/v1/ndr?count=1&id
Device=7b1afb61-b23a-4d42-95e0-5432f9592c6e’
- show quoted text -
…