Created
October 30, 2019 19:32
-
-
Save maurodelazeri/0608c5c6964ba972d52d56f4ff464cae to your computer and use it in GitHub Desktop.
ssl-check
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/bash | |
| RECIPIENT="mauro.delazeri@isprime.com"; | |
| DAYS=7; | |
| apache2ctl -S | grep "port 443 namevhost" | awk '{print $4}' | while read line;do | |
| TARGET=$line; | |
| echo "checking if $TARGET expires in less than $DAYS days"; | |
| expirationdate=$(date -d "$(: | openssl s_client -connect $TARGET:443 -servername $TARGET 2>/dev/null \ | |
| | openssl x509 -text \ | |
| | grep 'Not After' \ | |
| |awk '{print $4,$5,$7}')" '+%s'); | |
| in7days=$(($(date +%s) + (86400*$DAYS))); | |
| if [ $in7days -gt $expirationdate ]; then | |
| echo "KO - Certificate for $TARGET expires in less than $DAYS days, on $(date -d @$expirationdate '+%Y-%m-%d')" ; | |
| else | |
| echo "OK - Certificate expires on $expirationdate" | |
| fi; | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment