Skip to content

Instantly share code, notes, and snippets.

@414n
Created December 27, 2016 08:31
Show Gist options
  • Select an option

  • Save 414n/5982feb619cf50dc7691bcbb578ac6ca to your computer and use it in GitHub Desktop.

Select an option

Save 414n/5982feb619cf50dc7691bcbb578ac6ca to your computer and use it in GitHub Desktop.
Simple script to check SSL expiry date on a host:port pair using openssl tools
#!/bin/sh
usage () {
cat << EOF
Usage:
$(basename $0) host:port
to check for SSL certificate expiry date on the selected host and port
combination.
EOF
}
if [ $# -ne 1 ]
then
usage
exit 1
fi
HOSTPORT="$1"
openssl s_client -showcerts -connect "$HOSTPORT" < /dev/null 2>/dev/null \
| openssl x509 -enddate \
| awk -F'=' '/notAfter/ {print $2}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment