Skip to content

Instantly share code, notes, and snippets.

@wolfoo2931
Created December 17, 2018 13:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wolfoo2931/b2a9db0cf77bef74ebf9de99920cb419 to your computer and use it in GitHub Desktop.
Save wolfoo2931/b2a9db0cf77bef74ebf9de99920cb419 to your computer and use it in GitHub Desktop.
#!/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