From 70798de8f05e88e39fbcd70078b91b2ec07e9c83 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 31 Jul 2019 21:04:06 +0200 Subject: check-certificates: fix renewing certificate in place --- check-certificates | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'check-certificates') diff --git a/check-certificates b/check-certificates index 75ff938..d28ef86 100644 --- a/check-certificates +++ b/check-certificates @@ -45,23 +45,27 @@ :local CertNew [ / certificate find where common-name=($CertVal->"common-name") fingerprint!=[ :tostr ($CertVal->"fingerprint") ] expires-after>3w ]; :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 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") ]; - } on-error={ - :log debug ("Setting IPSEC certificates failed. Package 'security' not installed?"); - } + / ip service set certificate=($CertNewVal->"name") [ find where certificate=($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?"); - } + :do { + / 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") ]; + } on-error={ + :log debug ("Setting IPSEC certificates failed. Package 'security' 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") \ ("A certificate on " . $Identity . " has been renewed.\n\n" . \ -- cgit v1.2.3-70-g09d2