Skip to content

Instantly share code, notes, and snippets.

@yogeshkumark
Forked from stevebakh/retrieve-cert.sh
Created April 9, 2021 16:48
Show Gist options
  • Select an option

  • Save yogeshkumark/e1ced99e9d99a361c0d76b17d98f3c67 to your computer and use it in GitHub Desktop.

Select an option

Save yogeshkumark/e1ced99e9d99a361c0d76b17d98f3c67 to your computer and use it in GitHub Desktop.
Bash script using openssl to download website certificate
#!/bin/sh
#
# usage: retrieve-cert.sh remote.host.name [port]
#
REMHOST=$1
REMPORT=${2:-443}
echo |\
openssl s_client -connect ${REMHOST}:${REMPORT} 2>&1 |\
sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment