-
-
Save stef/895630 to your computer and use it in GitHub Desktop.
downloads and caches ssl certificates
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/bash | |
BASEDIR="$HOME/.ssl" | |
function get { | |
echo | openssl s_client -showcerts -connect "$1":"$2" 2>/dev/null | |
} | |
function md5 { | |
openssl x509 -md5 -fingerprint -noout | |
} | |
function sha1 { | |
openssl x509 -sha1 -fingerprint -noout | |
} | |
function cert { | |
openssl x509 -in "$BASEDIR/$1:$2" | |
} | |
function store { | |
f=`mktemp` | |
get "$1" "$2" | egrep -v '^\s*(Session-ID:|Master-Key:|Start Time:).*' | head -n -2 >"$f" | |
fname="$BASEDIR/$1:$2" | |
diff "$f" "$fname" >/dev/null 2>&1 || { | |
[[ -f "$fname" ]] && cp "$fname" "$fname.$(date +%s)" | |
mv "$f" "$fname" | |
} | |
} | |
store "$1" "$2" | |
egrep "^(issuer|subject)=" "$BASEDIR/$1:$2" | |
cert "$1" "$2" | md5 | |
cert "$1" "$2" | sha1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment