Last active
May 21, 2018 10:14
-
-
Save x43x61x69/5fe58c9b22b42004ce4965d3dee74653 to your computer and use it in GitHub Desktop.
Check SSL Certificate Info via Linux/macOS Command Line
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
# You can place this into '.bash_profile' to make it more accessible. | |
# sslstatus google.com:443 | |
sslstatus() | |
{ | |
echo | |
a=(${1//:/ }) | |
PORT=443 | |
if [ "${#a[@]}" -ne 2 ]; then | |
if [ "${#1}" -lt 1 ] || [[ "$1" =~ ":" ]]; then | |
echo "usage: ${0} HOST[:PORT]" | |
echo | |
echo "Note: If PORT was not provied, ${PORT} will be used by default." | |
return; | |
fi | |
else | |
PORT=(${a[1]}) | |
fi | |
HOST=(${a[0]}) | |
echo "Checking SSL Cert on host \"${HOST}\" for port ${PORT}..." | |
echo | |
echo | openssl s_client -servername "${HOST}" -connect "${HOST}:${PORT}" 2>/dev/null | openssl x509 -noout -issuer -subject -email -dates -pubkey -fingerprint | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment