check-certificates: show issuer CN only

This commit is contained in:
Christian Hesse 2019-01-09 17:34:08 +01:00
parent 57d93aa701
commit e51daf2761

View file

@ -10,6 +10,14 @@
:global SendNotification; :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={ :foreach Cert in=[ / certificate find where !revoked ] do={
:local CertName [ / certificate get $Cert name ]; :local CertName [ / certificate get $Cert name ];
:local ExpiresAfter [ / certificate get $Cert expires-after ]; :local ExpiresAfter [ / certificate get $Cert expires-after ];
@ -48,10 +56,11 @@
:local InvalidBefore [ / certificate get $CertNew invalid-before ]; :local InvalidBefore [ / certificate get $CertNew invalid-before ];
:local InvalidAfter [ / certificate get $CertNew invalid-after ]; :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 CommonName [ / certificate get $CertNew common-name ];
:set FingerPrint [ / certificate get $CertNew fingerprint ]; :set FingerPrint [ / certificate get $CertNew fingerprint ];
$SendNotification ("Certificate renewed") \ $SendNotification ("Certificate renewed") \
("A certificate on " . $Identity . " has been renewed.\n\n" . \ ("A certificate on " . $Identity . " has been renewed.\n\n" . \
"Certificate Name: " . $CertName . "\n" . \ "Certificate Name: " . $CertName . "\n" . \
@ -63,7 +72,7 @@
} on-error={ } on-error={
:local InvalidBefore [ / certificate get $Cert invalid-before ]; :local InvalidBefore [ / certificate get $Cert invalid-before ];
:local InvalidAfter [ / certificate get $Cert invalid-after ]; :local InvalidAfter [ / certificate get $Cert invalid-after ];
:local Issuer [ / certificate get $Cert issuer ]; :local Issuer [ $GetIssuerCN [ / certificate get $Cert issuer ] ];
$SendNotification ("Certificate warning!") \ $SendNotification ("Certificate warning!") \
("A certificate on " . $Identity . " is about to expire.\n\n" . \ ("A certificate on " . $Identity . " is about to expire.\n\n" . \