From e51daf276182dbd733f8eeec6122230790744e7b Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 9 Jan 2019 17:34:08 +0100 Subject: check-certificates: show issuer CN only --- check-certificates | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'check-certificates') diff --git a/check-certificates b/check-certificates index f0a466e..72a6fa8 100644 --- a/check-certificates +++ b/check-certificates @@ -10,6 +10,14 @@ :global SendNotification; +:local GetIssuerCN do={ + :foreach IssuerI in=$1 do={ + :if ([ :pick $IssuerI 0 3 ] = "CN=") do={ + :return $IssuerI; + } + } +} + :foreach Cert in=[ / certificate find where !revoked ] do={ :local CertName [ / certificate get $Cert name ]; :local ExpiresAfter [ / certificate get $Cert expires-after ]; @@ -48,10 +56,11 @@ :local InvalidBefore [ / certificate get $CertNew invalid-before ]; :local InvalidAfter [ / certificate get $CertNew invalid-after ]; - :local Issuer [ / certificate get $CertNew issuer ]; + :local Issuer [ $GetIssuerCN [ / certificate get $CertNew issuer ] ]; :set CommonName [ / certificate get $CertNew common-name ]; :set FingerPrint [ / certificate get $CertNew fingerprint ]; + $SendNotification ("Certificate renewed") \ ("A certificate on " . $Identity . " has been renewed.\n\n" . \ "Certificate Name: " . $CertName . "\n" . \ @@ -63,7 +72,7 @@ } on-error={ :local InvalidBefore [ / certificate get $Cert invalid-before ]; :local InvalidAfter [ / certificate get $Cert invalid-after ]; - :local Issuer [ / certificate get $Cert issuer ]; + :local Issuer [ $GetIssuerCN [ / certificate get $Cert issuer ] ]; $SendNotification ("Certificate warning!") \ ("A certificate on " . $Identity . " is about to expire.\n\n" . \ -- cgit v1.2.3-70-g09d2