Last active
December 10, 2015 19:58
-
-
Save ironsmile/4485041 to your computer and use it in GitHub Desktop.
This file contains 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/sh | |
if [ $# -lt 1 ] | |
then | |
echo "Usage: $0 remote.host.name [port]" | |
exit 1 | |
fi | |
REMHOST=$1 | |
REMPORT=${2:-443} | |
echo "Downloading certificate from ${REMHOST}:${REMPORT}..." | |
echo | openssl s_client -connect ${REMHOST}:${REMPORT} 2>&1 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /tmp/$REMHOST | |
echo "Adding certificate to ${HOME}/.pki/nssdb..." | |
certutil -d sql:$HOME/.pki/nssdb -A -t "C,," -n "$REMHOST" -i /tmp/$REMHOST | |
echo "Cleaning up..." | |
rm /tmp/$REMHOST | |
echo "Done" | |
# Get cert NotAfter date: | |
# echo | openssl s_client -connect my.ucdn.com:443 2>&1 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | openssl x509 -inform PEM -enddate -noout | cut -c 10- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment