Skip to content

Instantly share code, notes, and snippets.

@cesarmiquel
Last active February 3, 2019 22:02
Show Gist options
  • Save cesarmiquel/1a051c34b8753878d03291c121fe7d7a to your computer and use it in GitHub Desktop.
Save cesarmiquel/1a051c34b8753878d03291c121fe7d7a to your computer and use it in GitHub Desktop.
Check the expiration date on the SSL certificate of the given site.
#!/bin/bash
# -----------------------------------------------------------------------------------------
# Check the expiration date on the SSL certificate of the given site. Usate:
#
# $ ./check-ssl-certificate-expiration.sh www.google.com
#
# 🏵 Checking SSL certificate for https://www.google.com...
#
# Expiration date: Apr 9 13:15:00 2019 GMT
#
# Taken from:
# https://realguess.net/2016/10/11/a-cli-method-to-check-ssl-certificate-expiration-date/
# -----------------------------------------------------------------------------------------
SERVER=$1
echo
echo -e "\e[1;93m🏵 Checking SSL certificate for https://$SERVER...\e[0m"
echo
echo | openssl s_client -connect $SERVER:443 2> /dev/null | \
openssl x509 -noout -enddate | \
awk -P -F= '{print " Expiration date: " $2}'
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment