check-certificates: fix renewing certificate in place

This commit is contained in:
Christian Hesse 2019-07-31 21:04:06 +02:00
parent acce2322c3
commit 70798de8f0

View file

@ -45,24 +45,28 @@
:local CertNew [ / certificate find where common-name=($CertVal->"common-name") fingerprint!=[ :tostr ($CertVal->"fingerprint") ] expires-after>3w ]; :local CertNew [ / certificate find where common-name=($CertVal->"common-name") fingerprint!=[ :tostr ($CertVal->"fingerprint") ] expires-after>3w ];
:local CertNewVal [ / certificate get $CertNew ]; :local CertNewVal [ / certificate get $CertNew ];
/ ip service set certificate=($CertNewVal->"name") [ find where certificate=($CertVal->"name") ]; :if ($Cert != $CertNew) do={
:log debug ("Certificate '" . $CertVal->"name" . "' was not updated, but replaced.");
:do { / ip service set certificate=($CertNewVal->"name") [ find where certificate=($CertVal->"name") ];
/ ip ipsec identity set certificate=($CertNewVal->"name") [ / ip ipsec identity find where certificate=($CertVal->"name") ];
/ ip ipsec identity set remote-certificate=($CertNewVal->"name") [ / ip ipsec identity find where remote-certificate=($CertVal->"name") ]; :do {
} on-error={ / ip ipsec identity set certificate=($CertNewVal->"name") [ / ip ipsec identity find where certificate=($CertVal->"name") ];
:log debug ("Setting IPSEC certificates failed. Package 'security' not installed?"); / ip ipsec identity set remote-certificate=($CertNewVal->"name") [ / ip ipsec identity find where remote-certificate=($CertVal->"name") ];
} on-error={
:log debug ("Setting IPSEC certificates failed. Package 'security' not installed?");
}
:do {
/ ip hotspot profile set ssl-certificate=($CertNewVal->"name") [ / ip hotspot profile find where ssl-certificate=($CertVal->"name") ];
} on-error={
:log debug ("Setting hotspot certificates failed. Package 'hotspot' not installed?");
}
/ certificate remove $Cert;
/ certificate set $CertNew name=($CertVal->"name");
} }
:do {
/ ip hotspot profile set ssl-certificate=($CertNewVal->"name") [ / ip hotspot profile find where ssl-certificate=($CertVal->"name") ];
} on-error={
:log debug ("Setting hotspot certificates failed. Package 'hotspot' not installed?");
}
/ certificate remove $Cert;
/ certificate set $CertNew name=($CertVal->"name")
$SendNotification ("Certificate renewed") \ $SendNotification ("Certificate renewed") \
("A certificate on " . $Identity . " has been renewed.\n\n" . \ ("A certificate on " . $Identity . " has been renewed.\n\n" . \
"Name: " . ($CertVal->"name") . "\n" . \ "Name: " . ($CertVal->"name") . "\n" . \