Skip to content

Instantly share code, notes, and snippets.

@jeanouii
Created February 14, 2015 12:36
Show Gist options
  • Select an option

  • Save jeanouii/bf57c7ec865f3fcdc574 to your computer and use it in GitHub Desktop.

Select an option

Save jeanouii/bf57c7ec865f3fcdc574 to your computer and use it in GitHub Desktop.
  1. Calculate the signature using the provided service for the current date
curl -i -X POST -H "Content-Type: application/json" http://ec2-54-165-89-69.compute-1.amazonaws.com:8080/tribestream-signatures-0.52-SNAPSHOT/api/signatures/  \
-d '{
  "algorithm":"hmac-sha256",
  "headers":{
    "date":"Sat, 14 Feb 2015 13:30:13 CET",
    "digest":"md5=XUFAKrxLKna5cZ2REBfFkg=="
  },
  "keyId":"kids",
  "method":"POST",
  "requiredHeaders":"digest (request-target) date",
  "secretKey":"PennyLunaLuka",
  "uri":"/signature-prototype-1.0-SNAPSHOT/api/colors/preferred"
}'
Signature keyId="kids",algorithm="hmac-sha256",headers="digest (request-target) date",signature="/2OuE3VFbVZvkAlRFtzTu93GKZXgCSS6BKPgZeb4Hf0="
  1. Send the good request
curl -X POST -H 'Authorization: Signature keyId="kids",algorithm="hmac-sha256",headers="digest (request-target) date",signature="/2OuE3VFbVZvkAlRFtzTu93GKZXgCSS6BKPgZeb4Hf0="' \
 -H "Date: Sat, 14 Feb 2015 13:30:13 CET" \
 -H 'Digest: md5=XUFAKrxLKna5cZ2REBfFkg==' \
 http://ec2-54-165-89-69.compute-1.amazonaws.com:8080/signature-prototype-1.0-SNAPSHOT/api/colors/preferred \
 -d 'hello'
hello
  1. List keys
 curl -X PUT -u admin:admin -H "Content-Type: application/json" -H "Accept: application/json" http://ec2-54-165-89-69.compute-1.amazonaws.com:8080/console/api/management/keystore/secretkey/list \
-d '{
  "keystoreFile":"/srv/asp/prod/kids.jks",
  "keystorePass":"secret",
  "keystoreType":"JCEKS"
}'
{"storeType":"JCEKS","keys":[{"format":"RAW","alias":"kids","algorithm":"hmac-sha256","encoded":"PennyLunaLuka"}],"providerInfo":"SunJCE version 1.8"}
  1. Expired date
curl -X POST -H 'Authorization: Signature keyId="kids",algorithm="hmac-sha256",headers="digest (request-target) date",signature="/2OuE3VFbVZvkAlRFtzTu93GKZXgCSS6BKPgZeb4Hf0="' \
 -H "Date: Sat, 14 Feb 2000 13:30:13 CET" \
 -H 'Digest: md5=XUFAKrxLKna5cZ2REBfFkg==' \
 http://ec2-54-165-89-69.compute-1.amazonaws.com:8080/signature-prototype-1.0-SNAPSHOT/api/colors/preferred \
 -d 'hello'
HTTP 410 - Request Expired
  1. Wrond body
curl -v -X POST -H 'Authorization: Signature keyId="kids",algorithm="hmac-sha256",headers="digest (request-target) date",signature="/2OuE3VFbVZvkAlRFtzTu93GKZXgCSS6BKPgZeb4Hf0="' \
 -H "Date: Sat, 14 Feb 2015 13:30:13 CET" \
 -H 'Digest: md5=XUFAKrxLKna5cZ2REBfFkg==' \
 http://ec2-54-165-89-69.compute-1.amazonaws.com:8080/signature-prototype-1.0-SNAPSHOT/api/colors/preferred \
 -d 'hello not valid'
HTTP 400 Bad Request - Invalid Digest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment