Created
February 11, 2025 15:19
-
-
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"
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/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