Skip to content

Instantly share code, notes, and snippets.

@jkeam
Last active January 25, 2018 18:37
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 jkeam/06099d588d379b8e104bfead3158f94e to your computer and use it in GitHub Desktop.
Save jkeam/06099d588d379b8e104bfead3158f94e to your computer and use it in GitHub Desktop.
Get SSL Cert
#!/bin/sh
#
# usage: getcert.sh remote.host.name [port]
# eg) getcert.sh api.mailgun.net
#
RHOST=$1
RPORT=${2:-443}
# see cert
echo -n | openssl s_client -connect ${RHOST}:${RPORT} | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p'
# see chain
echo | openssl s_client -showcerts -servername ${RHOST} -connect ${RHOST}:${RPORT} 2>/dev/null | openssl x509 -inform pem -noout -text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment