aboutsummaryrefslogtreecommitdiffstats
path: root/prosodyctl
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2016-02-25 15:40:35 +0100
committerKim Alvefur <zash@zash.se>2016-02-25 15:40:35 +0100
commite8ae582f9096da3eb413f4b2dd31ac1a494f361c (patch)
tree510af1472114eea8f6d102eddf1506f3b8b7dcfa /prosodyctl
parent9a7bce4946a4a302905bdccd23ce59dc245803e8 (diff)
parent14ddd031ce06a21be7aae239b95cb393b3fb7f10 (diff)
downloadprosody-e8ae582f9096da3eb413f4b2dd31ac1a494f361c.tar.gz
prosody-e8ae582f9096da3eb413f4b2dd31ac1a494f361c.zip
Merge 0.10->trunk
Diffstat (limited to 'prosodyctl')
-rwxr-xr-xprosodyctl53
1 files changed, 33 insertions, 20 deletions
diff --git a/prosodyctl b/prosodyctl
index 3cbcde3b..44806436 100755
--- a/prosodyctl
+++ b/prosodyctl
@@ -698,30 +698,43 @@ function cert_commands.config(arg)
if use_existing(conf_filename) then
return nil, conf_filename;
end
+ local distinguished_name;
+ if arg[#arg]:find("^/") then
+ distinguished_name = table.remove(arg);
+ end
local conf = openssl.config.new();
conf:from_prosody(hosts, config, arg);
- show_message("Please provide details to include in the certificate config file.");
- show_message("Leave the field empty to use the default value or '.' to exclude the field.")
- for i, k in ipairs(openssl._DN_order) do
- local v = conf.distinguished_name[k];
- if v then
- local nv;
- if k == "commonName" then
- v = arg[1]
- elseif k == "emailAddress" then
- v = "xmpp@" .. arg[1];
- elseif k == "countryName" then
- local tld = arg[1]:match"%.([a-z]+)$";
- if tld and #tld == 2 and tld ~= "uk" then
- v = tld:upper();
+ if distinguished_name then
+ local dn = {};
+ for k, v in distinguished_name:gmatch("/([^=/]+)=([^/]+)") do
+ table.insert(dn, k);
+ dn[k] = v;
+ end
+ conf.distinguished_name = dn;
+ else
+ show_message("Please provide details to include in the certificate config file.");
+ show_message("Leave the field empty to use the default value or '.' to exclude the field.")
+ for i, k in ipairs(openssl._DN_order) do
+ local v = conf.distinguished_name[k];
+ if v then
+ local nv;
+ if k == "commonName" then
+ v = arg[1]
+ elseif k == "emailAddress" then
+ v = "xmpp@" .. arg[1];
+ elseif k == "countryName" then
+ local tld = arg[1]:match"%.([a-z]+)$";
+ if tld and #tld == 2 and tld ~= "uk" then
+ v = tld:upper();
+ end
end
+ nv = show_prompt(("%s (%s):"):format(k, nv or v));
+ nv = (not nv or nv == "") and v or nv;
+ if nv:find"[\192-\252][\128-\191]+" then
+ conf.req.string_mask = "utf8only"
+ end
+ conf.distinguished_name[k] = nv ~= "." and nv or nil;
end
- nv = show_prompt(("%s (%s):"):format(k, nv or v));
- nv = (not nv or nv == "") and v or nv;
- if nv:find"[\192-\252][\128-\191]+" then
- conf.req.string_mask = "utf8only"
- end
- conf.distinguished_name[k] = nv ~= "." and nv or nil;
end
end
local conf_file, err = io.open(conf_filename, "w");