Created
December 21, 2019 13:18
-
-
Save ckressibucher/064847d55a481965d98484de64bc6364 to your computer and use it in GitHub Desktop.
check expiration date of TLS certificate
This file contains 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/bash | |
hostname=$1 | |
expire_str=$(true | openssl s_client -connect $hostname:443 2>/dev/null | openssl x509 -noout -enddate | cut -d = -f2) | |
expire=$(date -d "$expire_str" +%s) | |
current=$(date +%s) | |
secs_left=$(expr $expire - $current) | |
days_left=$(expr $secs_left / 3600 / 24) | |
echo $hostname exires at $expire_str "(this is in $secs_left seconds, ~ $days_left days)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment