Created
September 16, 2019 18:02
-
-
Save bahamas10/58b50c47279340c418f74d14091a8819 to your computer and use it in GitHub Desktop.
manta function with piv signing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| function manta { | |
| local alg=ecdsa-sha256 | |
| local keyId=/$MANTA_USER/keys/$MANTA_KEY_ID | |
| local now=$(date -u "+%a, %d %h %Y %H:%M:%S GMT") | |
| local sig=$(echo "date: $now" | \ | |
| tr -d '\n' | \ | |
| ~/dev/buckets/node-sshpk-agent/sign) | |
| local path=$1 | |
| shift | |
| curl -k -sS "$MANTA_URL$path" "$@" -H "date: $now" \ | |
| -H "Authorization: Signature keyId=\"$keyId\",algorithm=\"$alg\",signature=\"$sig\"" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/node --no-deprecation | |
| var assert = require('assert'); | |
| var agent = require('./'); | |
| var fs = require('fs'); | |
| var data = fs.readFileSync('/dev/stdin', 'utf8'); | |
| var client = new agent.Client(); | |
| var key; | |
| client.listKeys(function (err, keys) { | |
| assert.ifError(err); | |
| keys.forEach(function (_key) { | |
| var comment = _key.comment; | |
| if (comment.split(' ')[0] === 'PIV_slot_9A') { | |
| key = _key; | |
| } | |
| }); | |
| assert(key); | |
| client.sign(key, data, function (err, sig) { | |
| assert.ifError(err); | |
| console.log(sig.toString()); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment