Skip to content

Instantly share code, notes, and snippets.

@rsalmond
Created August 16, 2018 22:01
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 rsalmond/7be6b42711bda50bc400a995effb939e to your computer and use it in GitHub Desktop.
Save rsalmond/7be6b42711bda50bc400a995effb939e to your computer and use it in GitHub Desktop.
#!/bin/bash
# fetch and decode SSL cert from a remote host
url=$1; shift
if [ -z "${url}" ]; then
echo "Usage: ${0} <url>"
fi
proto=$(echo ${url} | awk -F '[:/]' '{print $1}')
host=$(echo ${url} | awk -F '[:/]' '{print $4}')
if [[ -z "${proto}" || -z "${host}" ]]; then
echo "Unable to parse url. Must by in format 'http(s)://domain/'"
fi
if [ "${proto}" == "http" ]; then
port="80"
else
port="443"
fi
echo | openssl s_client -servername ${host} -connect ${host}:${port} 2>/dev/null | openssl x509 -noout -text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment