From 83d7a03ba4150ab1d796f0bbd3c6020e10d1224e Mon Sep 17 00:00:00 2001 From: silversword411 Date: Thu, 9 Sep 2021 12:56:16 -0400 Subject: [PATCH] adding cert checks --- troubleshoot_server.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/troubleshoot_server.sh b/troubleshoot_server.sh index 8d169a4a..ffa99aa0 100644 --- a/troubleshoot_server.sh +++ b/troubleshoot_server.sh @@ -68,6 +68,12 @@ else exit fi +while [[ $domain != *[.]* ]] +do +echo -ne "${YELLOW}Enter yourdomain used for letsencrypt (e.g. example.com)${NC}: " +read domain +done + echo -ne ${YELLOW} Checking IPs | tee -a checklog.log printf >&2 "\n\n" @@ -243,6 +249,22 @@ else printf >&2 "\n\n" fi + echo -ne ${YELLOW} Checking SSL Certificate is up to date | tee -a checklog.log + printf >&2 "\n\n" + +#SSL Certificate check +cert=$(openssl verify -CAfile /etc/letsencrypt/live/$domain/chain.pem /etc/letsencrypt/live/$domain/cert.pem) + +if [[ "$cert" == *"OK"* ]]; then + echo -ne ${GREEN} SSL Certificate for $domain is fine | tee -a checklog.log + printf >&2 "\n\n" + +else + echo -ne ${RED} SSL Certificate has expired or doesnt exist for $domain | tee -a checklog.log + printf >&2 "\n\n" +fi + + printf >&2 "\n\n" echo -ne ${YELLOW} printf >&2 "You will have a log file called checklog.log in the directory you ran this script from\n\n"