global-functions: $CertificateAvailable: check chain by akid and skid

We can merge this when RouterOS 6.47 moves to long-term...
This commit is contained in:
Christian Hesse 2020-04-03 16:39:30 +02:00
parent dad525173c
commit 0c2143298d

View file

@ -60,6 +60,7 @@
:global CertificateDownload; :global CertificateDownload;
:global LogPrintExit; :global LogPrintExit;
:global ParseKeyValueStore; :global ParseKeyValueStore;
:global RequiredRouterOS;
:if ([ / system resource get free-hdd-space ] < 8388608 && \ :if ([ / system resource get free-hdd-space ] < 8388608 && \
[ / certificate settings get crl-download ] = true && \ [ / certificate settings get crl-download ] = true && \
@ -75,19 +76,21 @@
} }
} }
:local CertVal; :if ([ $RequiredRouterOS ("\$CertificateAvailable") "6.47" ] = false) do={
:local Issuer $CommonName; :return true;
}
:local CertVal [ / certificate get [ find where common-name=$CommonName ] ];
:do { :do {
:if ([ :len [ / certificate find where common-name=$Issuer ] ] = 0) do={ :if ([ :len [ / certificate find where skid=($CertVal->"akid") ] ] = 0) do={
$LogPrintExit info ("Certificate chain for \"" . $CommonName . \ $LogPrintExit info ("Certificate chain for \"" . $CommonName . \
"\" is incomplete, missing \"" . $Issuer . "\".") false; "\" is incomplete, missing \"" . ([ $ParseKeyValueStore ($CertVal->"issuer") ]->"CN") . "\".") false;
:if ([ $CertificateDownload $CommonName ] = false) do={ :if ([ $CertificateDownload $CommonName ] = false) do={
:return false; :return false;
} }
} }
:set CertVal [ / certificate get [ find where common-name=$Issuer ] ]; :set CertVal [ / certificate get [ find where skid=($CertVal->"akid") ] ];
:set Issuer ([ $ParseKeyValueStore ($CertVal->"issuer") ]->"CN"); } while=(($CertVal->"akid") != "" && ($CertVal->"akid") != ($CertVal->"skid"));
} while=($Issuer != $CertVal->"common-name");
:return true; :return true;
} }
@ -1104,7 +1107,7 @@
} }
# check for required RouterOS version # check for required RouterOS version
$RequiredRouterOS "global-functions" "6.43"; $RequiredRouterOS "global-functions" "6.47";
# signal we are ready # signal we are ready
:set GlobalFunctionsReady true; :set GlobalFunctionsReady true;