From 9e7c20952eea9b04fe5f6f7424e30f4cee0faef6 Mon Sep 17 00:00:00 2001 From: vados-dev <192440777+vados-dev@users.noreply.github.com> Date: Wed, 15 Apr 2026 21:55:03 +0300 Subject: [PATCH] Autocommit in repo: ros.vados.ru, generated by owner: root, in 21:55:02 15.04.2026. --- html/AM-CustomCerts.rsc | 58 +++++++++++++++++++++++++++++++++++++++++ html/AM-GlobalFunc.rsc | 4 +-- 2 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 html/AM-CustomCerts.rsc diff --git a/html/AM-CustomCerts.rsc b/html/AM-CustomCerts.rsc new file mode 100644 index 000000000..f15bca982 --- /dev/null +++ b/html/AM-CustomCerts.rsc @@ -0,0 +1,58 @@ +#!rsc by Vados +# RouterOS script: AM-CertsRenew +# Script comment: Renew locally issued certificates +# Copyright (c) 2005-2026 Vados +# +# +# requires RouterOS, version=7.19 +# +:local ExitOK false; +:onerror Err { + :global GlobalConfReady; :global GlobalFuncReady; + :retry { :if ($GlobalConfReady != true || $GlobalFuncReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; + :local ScriptName [ :jobname ]; + + :global CertIssuedExportPass; + + :global LogPrint; + :global MkDir; + :global ScriptLock; + +# Add this Script scheduler +:if ([ :len [ /system/scheduler/find where name=$ScriptName ] ] = 0) do={ +:log warning ("System Scheduler for script: " . $ScriptName . " is NOT SET! Fix It Now!"); +:local OnEvent "/system/script/run $ScriptName;"; +:local Comment "Every Day Check For Update Local Issued Certificates."; +#/system/scheduler/add name=$ScriptName comment=$Comment start-time=startup interval=1d on-event=$OnEvent; +} + + :if ([ $ScriptLock $ScriptName ] = false) do={ + :set ExitOK true; + :error false; + } + + :foreach Cert in=[ /certificate/find where issued expires-after<3w ] do={ + :local CertVal [ /certificate/get $Cert ]; + /certificate/issued-revoke $Cert; + /certificate/set name=($CertVal->"name" . "-revoked-" . [ /system/clock/get date ]) $Cert; + /certificate/add name=($CertVal->"name") common-name=($CertVal->"common-name") \ + key-usage=($CertVal->"key-usage") subject-alt-name=($CertVal->"subject-alt-name"); + /certificate/sign ($CertVal->"name") ca=($CertVal->"ca"); + :if ([ :typeof ($CertIssuedExportPass->($CertVal->"common-name")) ] = "str") do={ + :if ([ $MkDir "cert-issued" ] = true) do={ + /certificate/export-certificate ($CertVal->"name") type=pkcs12 \ + file-name=("cert-issued/" . $CertVal->"common-name") \ + export-passphrase=($CertIssuedExportPass->($CertVal->"common-name")); + $LogPrint info $ScriptName ("Issued a new certificate for '" . $CertVal->"common-name" . \ + "', exported to 'cert-issued/" . $CertVal->"common-name" . ".p12'."); + } else={ + $LogPrint warning $ScriptName ("Failed creating directory, not exporting certificate."); + } + } else={ + $LogPrint info $ScriptName ("Issued a new certificate for '" . $CertVal->"common-name" . "'."); + } + } +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; +} diff --git a/html/AM-GlobalFunc.rsc b/html/AM-GlobalFunc.rsc index 5cec805e0..9084b7789 100644 --- a/html/AM-GlobalFunc.rsc +++ b/html/AM-GlobalFunc.rsc @@ -17,9 +17,9 @@ :global GlobalFuncReady false; # Git commit id & info, expected configuration version -:global CommitId "main/230/32ea8037"; +:global CommitId "main/231/47b67063"; :global CommitTAG "unknown"; -:global CommitInfo "Autocommit in repo: ros.vados.ru, generated by owner: root, in 20:45:02 15.04.2026."; +:global CommitInfo "Autocommit in repo: ros.vados.ru, generated by owner: root, in 21:55:02 15.04.2026."; # The variables are received right here. :global GlobalConfVersion 138; -- 2.52.0