Created
August 16, 2018 22:01
-
-
Save rsalmond/7be6b42711bda50bc400a995effb939e to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
# 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