Created
December 17, 2018 13:50
-
-
Save wolfoo2931/b2a9db0cf77bef74ebf9de99920cb419 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
cert_names=`credhub curl -p /api/v1/certificates | jq '.certificates | .[].name'` | |
for cert in $cert_names; do | |
cert_json=`credhub get -n $cert --output-json` | |
echo $cert_json | jq '.value | .ca' -r > /tmp/tmpca | |
echo $cert_json | jq '.value | .certificate' -r > /tmp/tmpcert | |
if [[ $(< /tmp/tmpca) != "null" ]]; then | |
date=$(openssl x509 -enddate -in /tmp/tmpca -noout | cut -d= -f 2) | |
echo "${date} -> ${cert}.ca" | |
fi | |
if [[ $(< /tmp/tmpcert) != "null" ]]; then | |
date=$(openssl x509 -enddate -in /tmp/tmpcert -noout | cut -d= -f 2) | |
echo "${date} -> ${cert}.certificate" | |
fi | |
rm /tmp/tmpca | |
rm /tmp/tmpcert | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment