Skip to content

Instantly share code, notes, and snippets.

@adjam
Created February 11, 2025 15:19
Show Gist options
  • Save adjam/56f1ae7c13eab7c9ef0151c924ac7f4b to your computer and use it in GitHub Desktop.
Save adjam/56f1ae7c13eab7c9ef0151c924ac7f4b to your computer and use it in GitHub Desktop.
checkcert -- shell script to quickly check whether a TLS cert is expiring "soon"
#!/bin/sh
OPTSTRING="d:"
DAYS=90
while getopts ${OPTSTRING} opt; do
case ${opt} in
d)
DAYS=${OPTARG}
;;
*)
;;
esac
done
shift $(($OPTIND -1 ))
HOSTNAME=${1}
echo "Host: $HOSTNAME, Days: ${DAYS}"
openssl x509 -noout -checkend $((86400 * $DAYS)) -in <(openssl s_client -showcerts -servername $HOSTNAME -connect $HOSTNAME:443 < /dev/null 2> /dev/null)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment