mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-08-11 05:35:29 +02:00
global-functions: $Certificate{Available,Download}: return and check status
This commit is contained in:
parent
c1c8d46dc0
commit
dfeaa1ed41
1 changed files with 9 additions and 2 deletions
|
@ -57,7 +57,9 @@
|
||||||
|
|
||||||
:if ([ / certificate print count-only where common-name=$CommonName ] = 0) do={
|
:if ([ / certificate print count-only where common-name=$CommonName ] = 0) do={
|
||||||
:log info ("Certificate with CommonName \"" . $CommonName . "\" not available.");
|
:log info ("Certificate with CommonName \"" . $CommonName . "\" not available.");
|
||||||
$CertificateDownload $CommonName;
|
:if ([ $CertificateDownload $CommonName ] = false) do={
|
||||||
|
:return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:local CertVal;
|
:local CertVal;
|
||||||
|
@ -65,11 +67,14 @@
|
||||||
:do {
|
:do {
|
||||||
:if ([ / certificate print count-only where common-name=$Issuer ] = 0) do={
|
:if ([ / certificate print count-only where common-name=$Issuer ] = 0) do={
|
||||||
:log info ("Certificate chain for \"" . $CommonName . "\" is incomplete, missing \"" . $Issuer . "\".");
|
:log info ("Certificate chain for \"" . $CommonName . "\" is incomplete, missing \"" . $Issuer . "\".");
|
||||||
$CertificateDownload $CommonName;
|
:if ([ $CertificateDownload $CommonName ] = false) do={
|
||||||
|
:return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
:set CertVal [ / certificate get [ find where common-name=$Issuer ] ];
|
:set CertVal [ / certificate get [ find where common-name=$Issuer ] ];
|
||||||
:set Issuer ([ $ParseKeyValueStore ($CertVal->"issuer") ]->"CN");
|
:set Issuer ([ $ParseKeyValueStore ($CertVal->"issuer") ]->"CN");
|
||||||
} while=($Issuer != $CertVal->"common-name");
|
} while=($Issuer != $CertVal->"common-name");
|
||||||
|
:return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
# download and import certificate
|
# download and import certificate
|
||||||
|
@ -101,7 +106,9 @@
|
||||||
}
|
}
|
||||||
} on-error={
|
} on-error={
|
||||||
:log warning "Failed imprting certificate!";
|
:log warning "Failed imprting certificate!";
|
||||||
|
:return false;
|
||||||
}
|
}
|
||||||
|
:return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
# name a certificate by its common-name
|
# name a certificate by its common-name
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue