mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-07-12 19:14:27 +02:00
check-certificates: fix renewing certificate in place
This commit is contained in:
parent
acce2322c3
commit
70798de8f0
1 changed files with 19 additions and 15 deletions
|
@ -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" . \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue