Skip to content

Instantly share code, notes, and snippets.

@rhietala
Created January 30, 2019 17:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rhietala/33f34a2f0f353835e5214a49c29d0f2c to your computer and use it in GitHub Desktop.
Save rhietala/33f34a2f0f353835e5214a49c29d0f2c to your computer and use it in GitHub Desktop.
#!/bin/bash
# Check SSL expiry dates
#
# This script can be used to check SSL certificate expiry dates for
# given list of domains.
#
#
# Usage
# ./check-ssl-expiry.sh
#
# Required commands (must be in path):
# openssl, grep, sed, sort
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
DOMAINS=(
www.google.com
www.microsoft.com
)
for domain in ${DOMAINS[*]}
do
expiryRaw=`echo | openssl s_client -servername $domain -connect $domain:443 2>/dev/null | openssl x509 -noout -dates | grep notAfter | sed 's/notAfter=//'`
expiry=`date -d "$expiryRaw" +%Y-%m-%d`
out+="$expiry $domain\n"
done
echo -e $out | sort
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment