mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
71ad56aacc
Copyright (C) 2013-2020 Christian Hesse <mail@eworm.de> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. https://www.gnu.org/licenses/#GPL https://www.gnu.org/licenses/gpl.html https://www.gnu.org/licenses/gpl.md
31 lines
1.4 KiB
Text
31 lines
1.4 KiB
Text
#!rsc
|
|
# RouterOS script: certificate-renew-issued
|
|
# Copyright (c) 2019-2020 Christian Hesse <mail@eworm.de>
|
|
# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
|
|
#
|
|
# renew locally issued certificates
|
|
# https://git.eworm.de/cgit/routeros-scripts/about/doc/certificate-renew-issued.md
|
|
|
|
:global CertIssuedExportPass;
|
|
|
|
:global LogPrintExit;
|
|
:global MkDir;
|
|
|
|
: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={
|
|
$MkDir "cert-issued";
|
|
/ certificate export-certificate ($CertVal->"name") type=pkcs12 \
|
|
file-name=("cert-issued/" . $CertVal->"common-name") \
|
|
export-passphrase=($CertIssuedExportPass->($CertVal->"common-name"));
|
|
$LogPrintExit info ("Issued a new certificate for \"" . $CertVal->"common-name" . \
|
|
"\", exported to \"cert-issued/" . $CertVal->"common-name" . ".p12\".") false;
|
|
} else={
|
|
$LogPrintExit info ("Issued a new certificate for \"" . $CertVal->"common-name" . "\".") false;
|
|
}
|
|
}
|