aboutsummaryrefslogtreecommitdiffstats
path: root/global-functions
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2020-02-06 18:09:52 +0100
committerGravatar Christian Hesse <mail@eworm.de>2020-02-06 18:18:56 +0100
commite376845b12441eb93e39d733aa1c8072b0056a84 (patch)
tree5935a098ca6a2e20540687504f7808c5d24fc72d /global-functions
parent38b23ddc10e414ece7e59f54d24bda5b4674b6f1 (diff)
global-functions: introduce and use $CertificateNameByCN
Diffstat (limited to 'global-functions')
-rw-r--r--global-functions15
1 files changed, 13 insertions, 2 deletions
diff --git a/global-functions b/global-functions
index caaf0a5..d4b8801 100644
--- a/global-functions
+++ b/global-functions
@@ -17,6 +17,7 @@
# global functions
:global UrlEncode;
:global CharacterReplace;
+:global CertificateNameByCN;
:global CertificateDownload;
:global CertificateAvailable;
:global SendEMail;
@@ -79,6 +80,16 @@
:return ($Return . $String);
}
+# name a certificate by its common-name
+:set CertificateNameByCN do={
+ :local CommonName [ :tostr $1 ];
+
+ :global CharacterReplace;
+
+ :local Cert [ / certificate find where common-name=$CommonName ];
+ / certificate set $Cert name=[ $CharacterReplace [ $CharacterReplace $CommonName " " "-" ] "---" "-" ];
+}
+
# download and import certificate
:set CertificateDownload do={
:local CommonName [ :tostr $1 ];
@@ -86,7 +97,7 @@
:global ScriptUpdatesBaseUrl;
:global ScriptUpdatesUrlSuffix;
- :global CharacterReplace;
+ :global CertificateNameByCN;
:global UrlEncode;
:global WaitForFile;
@@ -104,7 +115,7 @@
/ file remove $LocalFileName;
:foreach Cert in=[ / certificate find where name~("^" . $LocalFileName . "_[0-9]+\$") ] do={
- / certificate set $Cert name=[ $CharacterReplace [ $CharacterReplace [ get $Cert common-name ] " " "-" ] "---" "-" ];
+ $CertificateNameByCN [ / certificate get $Cert common-name ];
}
} on-error={
:log warning "Failed imprting certificate!";