mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
global-functions: import certificates if required
Signed-off-by: Christian Hesse <mail@eworm.de>
This commit is contained in:
parent
96fbb41b7e
commit
d81e1bf195
3 changed files with 76 additions and 3 deletions
|
@ -0,0 +1,51 @@
|
||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIDxTCCAq2gAwIBAgIBADANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMx
|
||||||
|
EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoT
|
||||||
|
EUdvRGFkZHkuY29tLCBJbmMuMTEwLwYDVQQDEyhHbyBEYWRkeSBSb290IENlcnRp
|
||||||
|
ZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIz
|
||||||
|
NTk1OVowgYMxCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQH
|
||||||
|
EwpTY290dHNkYWxlMRowGAYDVQQKExFHb0RhZGR5LmNvbSwgSW5jLjExMC8GA1UE
|
||||||
|
AxMoR28gRGFkZHkgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIw
|
||||||
|
DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL9xYgjx+lk09xvJGKP3gElY6SKD
|
||||||
|
E6bFIEMBO4Tx5oVJnyfq9oQbTqC023CYxzIBsQU+B07u9PpPL1kwIuerGVZr4oAH
|
||||||
|
/PMWdYA5UXvl+TW2dE6pjYIT5LY/qQOD+qK+ihVqf94Lw7YZFAXK6sOoBJQ7Rnwy
|
||||||
|
DfMAZiLIjWltNowRGLfTshxgtDj6AozO091GB94KPutdfMh8+7ArU6SSYmlRJQVh
|
||||||
|
GkSBjCypQ5Yj36w6gZoOKcUcqeldHraenjAKOc7xiID7S13MMuyFYkMlNAJWJwGR
|
||||||
|
tDtwKj9useiciAF9n9T521NtYJ2/LOdYq7hfRvzOxBsDPAnrSTFcaUaz4EcCAwEA
|
||||||
|
AaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYE
|
||||||
|
FDqahQcQZyi27/a9BUFuIMGU2g/eMA0GCSqGSIb3DQEBCwUAA4IBAQCZ21151fmX
|
||||||
|
WWcDYfF+OwYxdS2hII5PZYe096acvNjpL9DbWu7PdIxztDhC2gV7+AJ1uP2lsdeu
|
||||||
|
9tfeE8tTEH6KRtGX+rcuKxGrkLAngPnon1rpN5+r5N9ss4UXnT3ZJE95kTXWXwTr
|
||||||
|
gIOrmgIttRD02JDHBHNA7XIloKmf7J6raBKZV8aPEjoJpL1E/QYVN8Gb5DKj7Tjo
|
||||||
|
2GTzLH4U/ALqn83/B2gX2yKQOC16jdFU8WnjXzPKej17CuPKf1855eJ1usV2GDPO
|
||||||
|
LPAvTK33sefOT6jEm0pUBsV/fdUID+Ic/n4XuKxe9tQWskMJDE32p2u0mYRlynqI
|
||||||
|
4uJEvlz36hz1
|
||||||
|
-----END CERTIFICATE-----
|
||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIE0DCCA7igAwIBAgIBBzANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMx
|
||||||
|
EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoT
|
||||||
|
EUdvRGFkZHkuY29tLCBJbmMuMTEwLwYDVQQDEyhHbyBEYWRkeSBSb290IENlcnRp
|
||||||
|
ZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTExMDUwMzA3MDAwMFoXDTMxMDUwMzA3
|
||||||
|
MDAwMFowgbQxCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQH
|
||||||
|
EwpTY290dHNkYWxlMRowGAYDVQQKExFHb0RhZGR5LmNvbSwgSW5jLjEt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BCwUAA4IBAQAIfmyTEMg4uJapkEv/oV9PBO9sPpyIBslQj6Zz
|
||||||
|
91cxG7685C/b+LrTW+C05+Z5Yg4MotdqY3MxtfWoSKQ7CC2iXZDXtHwlTxFWMMS2
|
||||||
|
RJ17LJ3lXubvDGGqv+QqG+6EnriDfcFDzkSnE3ANkR/0yBOtg2DZ2HKocyQetawi
|
||||||
|
DsoXiWJYRBuriSUBAA/NxBti21G00w9RKpv0vHP8ds42pM3Z2Czqrpv1KrKQ0U11
|
||||||
|
GIo/ikGQI31bS/6kA1ibRrLDYGCD+H1QQc7CoZDDu+8CL9IVVO5EFdkKrqeKM+2x
|
||||||
|
LXY2JtwE65/3YR8V3Idv7kaWKK2hJn0KCacuBKONvPi8BDAB
|
||||||
|
-----END CERTIFICATE-----
|
1
certs/godaddy.pem
Symbolic link
1
certs/godaddy.pem
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
973a41276ffd01e027a2aad49e34c37846d3e976ff6a620b6712e33832041aa6.pem
|
|
@ -27,6 +27,28 @@
|
||||||
:return $return;
|
:return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# check and import required certificates
|
||||||
|
:global CertificateAvailable do={
|
||||||
|
:local fprint [ :tostr $1 ];
|
||||||
|
|
||||||
|
:global "script-updates-baseurl";
|
||||||
|
:global "script-updates-urlsuffix";
|
||||||
|
|
||||||
|
:if ([ :len [ / certificate find where fingerprint=$fprint ] ] = 0) do={
|
||||||
|
:log info ("Certificate with fingerprint " . $fprint . \
|
||||||
|
" not available, downloading and importing.");
|
||||||
|
:do {
|
||||||
|
/ tool fetch check-certificate=yes-without-crl \
|
||||||
|
($"script-updates-baseurl" . "certs/" . \
|
||||||
|
$fprint . ".pem" . $"script-updates-urlsuffix") \
|
||||||
|
dst-path=($fprint . ".pem");
|
||||||
|
/ certificate import file-name=($fprint . ".pem") passphrase="";
|
||||||
|
} on-error={
|
||||||
|
:log warning "Failed imprting certificate!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# send notification via e-mail and telegram
|
# send notification via e-mail and telegram
|
||||||
# Note that subject and attachment are ignored for telegram!
|
# Note that subject and attachment are ignored for telegram!
|
||||||
:global SendNotification do={
|
:global SendNotification do={
|
||||||
|
@ -40,6 +62,7 @@
|
||||||
:global "telegram-chatid";
|
:global "telegram-chatid";
|
||||||
|
|
||||||
:global UrlEncode;
|
:global UrlEncode;
|
||||||
|
:global CertificateAvailable;
|
||||||
|
|
||||||
:if ([ :len $"email-general-to" ] > 0) do={
|
:if ([ :len $"email-general-to" ] > 0) do={
|
||||||
:do {
|
:do {
|
||||||
|
@ -50,10 +73,8 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# You need to import the certificate chain for api.telegram.org!
|
|
||||||
# https://certs.godaddy.com/repository/gdroot-g2.crt
|
|
||||||
# https://certs.godaddy.com/repository/gdig2.crt.pem
|
|
||||||
:if ([ :len $"telegram-tokenid" ] > 0 && [ :len $"telegram-chatid" ] > 0) do={
|
:if ([ :len $"telegram-tokenid" ] > 0 && [ :len $"telegram-chatid" ] > 0) do={
|
||||||
|
$CertificateAvailable "973a41276ffd01e027a2aad49e34c37846d3e976ff6a620b6712e33832041aa6";
|
||||||
:do {
|
:do {
|
||||||
/ tool fetch check-certificate=yes-without-crl keep-result=no http-method=post \
|
/ tool fetch check-certificate=yes-without-crl keep-result=no http-method=post \
|
||||||
("https://api.telegram.org/bot" . $"telegram-tokenid" . "/sendMessage") \
|
("https://api.telegram.org/bot" . $"telegram-tokenid" . "/sendMessage") \
|
||||||
|
|
Loading…
Reference in a new issue