Created
November 30, 2012 22:27
-
-
Save simonwhitaker/4179149 to your computer and use it in GitHub Desktop.
Get the expiry date of a secure website's SSL certificate at the command line
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 | |
ssl_expiry() { | |
# Show usage info if not called with a hostname | |
if [ $# -eq 0 ]; then | |
echo "Usage: ssl_expiry HOSTNAME" | |
return 0 | |
fi | |
domain=$1 | |
output=$(echo | openssl s_client -connect ${domain}:443 2>/dev/null | openssl x509 -enddate -noout) | |
# Output will look something like 'notAfter=May 10 23:59:59 2014 GMT' | |
# Split on = to remove the 'notAfter=' portion | |
end_date=${output##*=} | |
echo $domain $end_date | |
} | |
ssl_expiry $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment