aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2020-07-16 21:18:12 +0200
committerGravatar Christian Hesse <mail@eworm.de>2020-07-16 21:18:12 +0200
commit6dfd8ed41a18a10dd6c640bb0dfc37f1a561ee8c (patch)
treec12a6b62cc488557cc136464293ecc4b256f7c9e
parent4c61cd0b650d6bab1aafb32f1d1100fa4bb2f7fe (diff)
check-certificates: use $IfThenElse
-rw-r--r--check-certificates10
1 files changed, 3 insertions, 7 deletions
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;
}