Skip to content
Snippets Groups Projects
Commit 8f09470d authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

check_ssl: shell fixes

parent 05ceafd3
No related branches found
No related tags found
1 merge request!55Add check requirement
...@@ -16,10 +16,11 @@ ...@@ -16,10 +16,11 @@
# #
# 2017-03-03 v1.0 ah,ds # 2017-03-03 v1.0 ah,ds
# 2020-03-05 v1.1 <axel.hahn@iml.unibe.ch> switch to ph.* helper functions # 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= sDomain=
iPort=443 iPort=443
...@@ -41,7 +42,7 @@ function showHelp(){ ...@@ -41,7 +42,7 @@ function showHelp(){
echo echo
echo ----- SSL Check v1.0 echo ----- SSL Check v1.0
echo echo
echo "SYNTAX: `basename $0` [domain] [[port]]" echo "SYNTAX: $(basename $0) [domain] [[port]]"
echo " domain - domain to verify the ssl vertificate from (required)" echo " domain - domain to verify the ssl vertificate from (required)"
echo " port - port number to connect (default: 443)" echo " port - port number to connect (default: 443)"
echo echo
...@@ -81,7 +82,7 @@ function showHelp(){ ...@@ -81,7 +82,7 @@ function showHelp(){
ph.exit ph.exit
fi 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 if [ $? -ne 0 ]; then
ph.setStatus "unknown" ph.setStatus "unknown"
echo SORRY, openssl was unable to fetch the right certificate - this happens on multiple ssl webs - it finds echo SORRY, openssl was unable to fetch the right certificate - this happens on multiple ssl webs - it finds
...@@ -91,13 +92,13 @@ function showHelp(){ ...@@ -91,13 +92,13 @@ function showHelp(){
# --- unix timestamps valid from .. to # --- unix timestamps valid from .. to
dateFrom=`echo | openssl s_client -connect ${sDomain}:${iPort} 2>/dev/null | openssl x509 -noout -startdate | 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 "="` dateTo=$(echo | openssl s_client -connect ${sDomain}:${iPort} 2>/dev/null | openssl x509 -noout -enddate | cut -f 2 -d "=")
tsFrom=`date -d "${dateFrom}" +%s` tsFrom=$(date -d "${dateFrom}" +%s)
tsTo=`date -d "${dateTo}" +%s` tsTo=$(date -d "${dateTo}" +%s)
tsNow=`date +%s` tsNow=$(date +%s)
typeset -i iDaysLeft=($tsTo-$tsNow)/60/60/24 typeset -i iDaysLeft=($tsTo-$tsNow)/60/60/24
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment