check_https_valid: adjust string
This commit is contained in:
parent
28909ae35f
commit
5704302e33
|
@ -42,22 +42,22 @@ curl_exit_code=$?
|
||||||
if [ $curl_exit_code -ne 0 ]; then
|
if [ $curl_exit_code -ne 0 ]; then
|
||||||
case $curl_exit_code in
|
case $curl_exit_code in
|
||||||
6)
|
6)
|
||||||
MSG="Could not resolve host for $url"
|
MSG="Could not resolve host for \"$url\""
|
||||||
;;
|
;;
|
||||||
7)
|
7)
|
||||||
MSG="Failed to connect to $url"
|
MSG="Failed to connect to \"$url\""
|
||||||
;;
|
;;
|
||||||
35)
|
35)
|
||||||
MSG="SSL connect error for $url"
|
MSG="SSL connect error for \"$url\""
|
||||||
;;
|
;;
|
||||||
51)
|
51)
|
||||||
MSG="SSL certificate verification failed for $url"
|
MSG="SSL certificate verification failed for \"$url\""
|
||||||
;;
|
;;
|
||||||
60)
|
60)
|
||||||
MSG="SSL certificate cannot be authenticated with known CA certificates for $url"
|
MSG="SSL certificate cannot be authenticated with known CA certificates for \"$url\""
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
MSG="curl request failed with exit code $curl_exit_code for $url"
|
MSG="curl request failed with exit code $curl_exit_code for \"$url\""
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
echo "CRITICAL - $MSG"
|
echo "CRITICAL - $MSG"
|
||||||
|
@ -68,7 +68,7 @@ fi
|
||||||
expiration_date=$(echo | openssl s_client -servername "$hostname" -connect "$hostname:$port" 2>/dev/null | openssl x509 -noout -enddate | cut -d "=" -f 2)
|
expiration_date=$(echo | openssl s_client -servername "$hostname" -connect "$hostname:$port" 2>/dev/null | openssl x509 -noout -enddate | cut -d "=" -f 2)
|
||||||
|
|
||||||
if [ -z "$expiration_date" ]; then
|
if [ -z "$expiration_date" ]; then
|
||||||
echo "UNKNOWN - Failed to retrieve SSL certificate expiration date for $url"
|
echo "UNKNOWN - Failed to retrieve SSL certificate expiration date for \"$url\""
|
||||||
exit 3
|
exit 3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -76,16 +76,16 @@ expiration_timestamp=$(date -d "$expiration_date" +%s)
|
||||||
current_timestamp=$(date +%s)
|
current_timestamp=$(date +%s)
|
||||||
|
|
||||||
if [ $expiration_timestamp -lt $current_timestamp ]; then
|
if [ $expiration_timestamp -lt $current_timestamp ]; then
|
||||||
echo "CRITICAL - SSL certificate for $url has expired on $(date -d @$expiration_timestamp)"
|
echo "CRITICAL - SSL certificate for \"$url\" has expired on $(date -d @$expiration_timestamp)"
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
days_remaining=$((($expiration_timestamp - $current_timestamp) / (60*60*24)))
|
days_remaining=$((($expiration_timestamp - $current_timestamp) / (60*60*24)))
|
||||||
|
|
||||||
if [ $days_remaining -lt 30 ]; then
|
if [ $days_remaining -lt 30 ]; then
|
||||||
echo "WARNING - SSL certificate for $url is expiring on $(date -d @$expiration_timestamp) ($days_remaining days remaining)"
|
echo "WARNING - SSL certificate for \"$url\" is expiring on $(date -d @$expiration_timestamp) ($days_remaining days remaining)"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
echo "OK - SSL certificate for $url is valid"
|
echo "OK - SSL certificate for \"$url\" is valid"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue