From 6dfd8ed41a18a10dd6c640bb0dfc37f1a561ee8c Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 16 Jul 2020 21:18:12 +0200 Subject: check-certificates: use $IfThenElse --- check-certificates | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'check-certificates') diff --git a/check-certificates b/check-certificates index 9e65586..1402e49 100644 --- a/check-certificates +++ b/check-certificates @@ -12,6 +12,7 @@ :global CertificateAvailable :global CertificateNameByCN; +:global IfThenElse; :global LogPrintExit; :global ParseKeyValueStore; :global SendNotification; @@ -104,12 +105,7 @@ :if ([ / certificate scep-server print count-only where ca-cert=($CertVal->"ca") ] > 0) do={ $LogPrintExit debug ("Certificate \"" . ($CertVal->"name") . "\" is handled by SCEP, skipping.") false; } else={ - :local ExpiresAfter [ $FormatExpire ($CertVal->"expires-after") ]; - :local State "is about to expire"; - :if (($CertVal->"expired") = true) do={ - :set ExpiresAfter "expired"; - :set State "expired"; - } + :local State [ $IfThenElse (($CertVal->"expired") = true) "expired" "is about to expire" ]; $SendNotification ("Certificate warning!") \ ("A certificate on " . $Identity . " " . $State . ".\n\n" . \ @@ -118,7 +114,7 @@ "Fingerprint: " . ($CertVal->"fingerprint") . "\n" . \ "Issuer: " . ($CertVal->"ca") . ([ $ParseKeyValueStore ($CertVal->"issuer") ]->"CN") . "\n" . \ "Validity: " . ($CertVal->"invalid-before") . " to " . ($CertVal->"invalid-after") . "\n" . \ - "Expires in: " . $ExpiresAfter); + "Expires in: " . [ $IfThenElse (($CertVal->"expired") = true) "expired" [ $FormatExpire ($CertVal->"expires-after") ] ]); $LogPrintExit warning ("The certificate " . ($CertVal->"name") . " " . $State . \ ", it is invalid after " . ($CertVal->"invalid-after") . ".") false; } -- cgit v1.2.3-70-g09d2