diff --git a/check_ssl_certs b/check_ssl_certs index b4d52b84790ba31f9946f85b80667f4249c22030..9604ceb8713bf56afbaaceb343d96bbdc1f6a3a1 100755 --- a/check_ssl_certs +++ b/check_ssl_certs @@ -13,9 +13,11 @@ # 2021-10-06 v0.1 <axel.hahn@iml.unibe.ch> initial version # 2022-03-16 v0.2 <axel.hahn@iml.unibe.ch> shell fixes; shorten perfdata label # 2022-10-21 v1.3 <axel.hahn@unibe.ch> remove grep: warning: stray \ before white space +# 2024-04-24 v1.4 <axel.hahn@unibe.ch> update for newer openssl version; update help # ====================================================================== . $(dirname $0)/inc_pluginfunctions +self_APPVERSION=1.4 typeset -i iWarn=14 typeset -i iCrit=5 @@ -36,15 +38,11 @@ myDomain=".iml.unibe.ch" # functions # ---------------------------------------------------------------------- +# show help text function showHelp(){ + local _self; _self=$(basename $0) cat <<EOF -______________________________________________________________________ - -CHECK_SSL_CERTS - -(c) Institute for Medical Education - University of Bern -Licence: GNU GPL 3 -______________________________________________________________________ +$( ph.showImlHelpHeader ) Check locally installed SSL client certificates and warn if the expiration date comes closer. @@ -118,7 +116,7 @@ for mycert in $( ls -1 $filelist 2>/dev/null ) do iCounter=$iCounter+1 data=$(openssl x509 -noout -text -in $mycert 2>/dev/null ) - mySubject=$( echo "$data" | grep "Subject: CN = " | grep -v "," | cut -f 2- -d "=" | cut -c 2- ) + mySubject=$( echo "$data" | grep "Subject: CN *= *" | grep -v "," | cut -f 2- -d "=" | tr -d ' ' ) mySubject2="${mySubject//${myDomain}}" if [ -z "$mySubject" ]; then @@ -149,7 +147,7 @@ do fi shortstatus="${shortstatus}${result} ${mySubject} [${iLeft}d] ; " fullstatus="${fullstatus} ------ [$iCounter of $iTotal] ${mySubject} - expires in $iLeft days $mySubject2 +----- [$iCounter of $iTotal] ${mySubject} - expires in $iLeft days $( echo "$data" | grep -E "(DNS:|Issuer:|Not |Subject:)" | sed 's#^ *##g') File: $mycert "