diff --git a/check_ssl b/check_ssl index e9ad81095c96807c7b5ede0a0852556226b14df2..e80f5d9b5def8438eb762e09970a24ea022adaa0 100755 --- a/check_ssl +++ b/check_ssl @@ -16,10 +16,11 @@ # # 2017-03-03 v1.0 ah,ds # 2020-03-05 v1.1 <axel.hahn@iml.unibe.ch> switch to ph.* helper functions +# 2023-02-13 v1.2 <axel.hahn@unibe.ch> some shell fixes # ====================================================================== -. `dirname $0`/inc_pluginfunctions +. $(dirname $0)/inc_pluginfunctions sDomain= iPort=443 @@ -41,7 +42,7 @@ function showHelp(){ echo echo ----- SSL Check v1.0 echo - echo "SYNTAX: `basename $0` [domain] [[port]]" + echo "SYNTAX: $(basename $0) [domain] [[port]]" echo " domain - domain to verify the ssl vertificate from (required)" echo " port - port number to connect (default: 443)" echo @@ -81,7 +82,7 @@ function showHelp(){ ph.exit fi - echo | openssl s_client -connect ${sDomain}:${iPort} 2>/dev/null | openssl x509 -noout -subject | fgrep ${sDomain} >/dev/null + echo | openssl s_client -connect ${sDomain}:${iPort} 2>/dev/null | openssl x509 -noout -subject | grep -F ${sDomain} >/dev/null if [ $? -ne 0 ]; then ph.setStatus "unknown" echo SORRY, openssl was unable to fetch the right certificate - this happens on multiple ssl webs - it finds @@ -91,13 +92,13 @@ function showHelp(){ # --- unix timestamps valid from .. to - dateFrom=`echo | openssl s_client -connect ${sDomain}:${iPort} 2>/dev/null | openssl x509 -noout -startdate | cut -f 2 -d "="` - dateTo=`echo | openssl s_client -connect ${sDomain}:${iPort} 2>/dev/null | openssl x509 -noout -enddate | cut -f 2 -d "="` + dateFrom=$(echo | openssl s_client -connect ${sDomain}:${iPort} 2>/dev/null | openssl x509 -noout -startdate | cut -f 2 -d "=") + dateTo=$(echo | openssl s_client -connect ${sDomain}:${iPort} 2>/dev/null | openssl x509 -noout -enddate | cut -f 2 -d "=") - tsFrom=`date -d "${dateFrom}" +%s` - tsTo=`date -d "${dateTo}" +%s` + tsFrom=$(date -d "${dateFrom}" +%s) + tsTo=$(date -d "${dateTo}" +%s) - tsNow=`date +%s` + tsNow=$(date +%s) typeset -i iDaysLeft=($tsTo-$tsNow)/60/60/24