mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-08-13 22:48:42 +02:00
Merge branch 'check-certificates' into next
This commit is contained in:
commit
24de060904
1 changed files with 15 additions and 10 deletions
|
@ -48,21 +48,26 @@
|
||||||
:global UrlEncode;
|
:global UrlEncode;
|
||||||
:global WaitForFile;
|
:global WaitForFile;
|
||||||
|
|
||||||
:local Return false;
|
:foreach Type in={ "p12"; "pem" } do={
|
||||||
|
:local CertFileName ([ $UrlEncode $FetchName ] . "." . $Type);
|
||||||
|
$LogPrint debug $ScriptName ("Trying type '" . $Type . "' for '" . $CertName . \
|
||||||
|
"' (file '" . $CertFileName . "')...");
|
||||||
|
|
||||||
:foreach Type in={ ".pem"; ".p12" } do={
|
|
||||||
:local CertFileName ([ $UrlEncode $FetchName ] . $Type);
|
|
||||||
:do {
|
:do {
|
||||||
/tool/fetch check-certificate=yes-without-crl http-header-field=({ [ $FetchUserAgentStr $ScriptName ] }) \
|
/tool/fetch check-certificate=yes-without-crl http-header-field=({ [ $FetchUserAgentStr $ScriptName ] }) \
|
||||||
($CertRenewUrl . $CertFileName) dst-path=$CertFileName as-value;
|
($CertRenewUrl . $CertFileName) dst-path=$CertFileName as-value;
|
||||||
$WaitForFile $CertFileName;
|
$WaitForFile $CertFileName;
|
||||||
|
|
||||||
:local DecryptionFailed true;
|
:local DecryptionFailed true;
|
||||||
:foreach PassPhrase in=$CertRenewPass do={
|
:foreach I,PassPhrase in=$CertRenewPass do={
|
||||||
:local Result [ /certificate/import file-name=$CertFileName passphrase=$PassPhrase as-value ];
|
:do {
|
||||||
:if ($Result->"decryption-failures" = 0) do={
|
$LogPrint debug $ScriptName ("Trying " . $I . ". passphrase... ");
|
||||||
:set DecryptionFailed false;
|
:local Result [ /certificate/import file-name=$CertFileName passphrase=$PassPhrase as-value ];
|
||||||
}
|
:if ($Result->"decryption-failures" = 0) do={
|
||||||
|
$LogPrint debug $ScriptName ("Success!");
|
||||||
|
:set DecryptionFailed false;
|
||||||
|
}
|
||||||
|
} on-error={ }
|
||||||
}
|
}
|
||||||
$RmFile $CertFileName;
|
$RmFile $CertFileName;
|
||||||
|
|
||||||
|
@ -77,13 +82,13 @@
|
||||||
$CertificateNameByCN [ /certificate/get $CertInChain common-name ];
|
$CertificateNameByCN [ /certificate/get $CertInChain common-name ];
|
||||||
}
|
}
|
||||||
|
|
||||||
:set Return true;
|
:return true;
|
||||||
} on-error={
|
} on-error={
|
||||||
$LogPrint debug $ScriptName ("Could not download certificate file '" . $CertFileName . "'.");
|
$LogPrint debug $ScriptName ("Could not download certificate file '" . $CertFileName . "'.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:return $Return;
|
:return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
:local FormatInfo do={
|
:local FormatInfo do={
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue