Skip to content

Instantly share code, notes, and snippets.

@MelindaShore
Created May 28, 2020 05:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MelindaShore/db375789690cc6f194340b9354f29c51 to your computer and use it in GitHub Desktop.
Save MelindaShore/db375789690cc6f194340b9354f29c51 to your computer and use it in GitHub Desktop.
ocsp checker shell script - convenient but not very robust
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo Usage: $0 servername
exit 1
fi
servername=$1
cert=$servername.pem
openssl s_client -connect $servername:443 2>&1 < /dev/null | sed -n '/-----BEGIN/,/-----END/p' >$cert
responder=`openssl x509 -ocsp_uri -in $cert -noout`
cakey=`openssl x509 -text -in $cert | grep "CA Issuers" | sed 's/^.*URI://'`
curl -s $cakey >`basename $cakey`
capem=`basename -s .der $cakey`.pem
openssl x509 -inform DER -outform PEM -in `basename $cakey` -out $capem
openssl ocsp -no_nonce -issuer $capem -cert $cert -url $responder -header HOST `echo $responder|sed -e 's;http://;;' -e 's;/.*$;;'` 2>/dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment