mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
global-functions: $CertificateDownload: download via clean name...
... and rename certificates in repository.
This commit is contained in:
parent
eb7919c1d8
commit
cd371b69a6
9 changed files with 8 additions and 9 deletions
|
@ -136,25 +136,24 @@
|
||||||
:global ScriptUpdatesUrlSuffix;
|
:global ScriptUpdatesUrlSuffix;
|
||||||
|
|
||||||
:global CertificateNameByCN;
|
:global CertificateNameByCN;
|
||||||
|
:global CleanName;
|
||||||
:global FetchUserAgent;
|
:global FetchUserAgent;
|
||||||
:global LogPrint;
|
:global LogPrint;
|
||||||
:global UrlEncode;
|
|
||||||
:global WaitForFile;
|
:global WaitForFile;
|
||||||
|
|
||||||
$LogPrint info $0 ("Downloading and importing certificate with " . \
|
$LogPrint info $0 ("Downloading and importing certificate with " . \
|
||||||
"CommonName \"" . $CommonName . "\".");
|
"CommonName \"" . $CommonName . "\".");
|
||||||
:do {
|
:do {
|
||||||
:local LocalFileName ($CommonName . ".pem");
|
:local FileName ([ $CleanName $CommonName ] . ".pem");
|
||||||
:local UrlFileName ([ $UrlEncode $CommonName ] . ".pem");
|
|
||||||
/tool/fetch check-certificate=yes-without-crl http-header-field=({ [ $FetchUserAgent $0 ] }) \
|
/tool/fetch check-certificate=yes-without-crl http-header-field=({ [ $FetchUserAgent $0 ] }) \
|
||||||
($ScriptUpdatesBaseUrl . "certs/" . $UrlFileName . $ScriptUpdatesUrlSuffix) \
|
($ScriptUpdatesBaseUrl . "certs/" . $FileName . $ScriptUpdatesUrlSuffix) \
|
||||||
dst-path=$LocalFileName as-value;
|
dst-path=$FileName as-value;
|
||||||
$WaitForFile $LocalFileName;
|
$WaitForFile $FileName;
|
||||||
/certificate/import file-name=$LocalFileName passphrase="" as-value;
|
/certificate/import file-name=$FileName passphrase="" as-value;
|
||||||
:delay 1s;
|
:delay 1s;
|
||||||
/file/remove $LocalFileName;
|
/file/remove $FileName;
|
||||||
|
|
||||||
:foreach Cert in=[ /certificate/find where name~("^" . $LocalFileName . "_[0-9]+\$") ] do={
|
:foreach Cert in=[ /certificate/find where name~("^" . $FileName . "_[0-9]+\$") ] do={
|
||||||
$CertificateNameByCN [ /certificate/get $Cert common-name ];
|
$CertificateNameByCN [ /certificate/get $Cert common-name ];
|
||||||
}
|
}
|
||||||
} on-error={
|
} on-error={
|
||||||
|
|
Loading…
Reference in a new issue