aboutsummaryrefslogtreecommitdiffstats
path: root/prosodyctl
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2013-05-01 13:45:42 +0100
committerMatthew Wild <mwild1@gmail.com>2013-05-01 13:45:42 +0100
commit333918c20296b46b7cd26a54cba1b4c3d51e5862 (patch)
tree3e00cd2af58e4602779b13c51761bd86b48ea264 /prosodyctl
parent105c76f9673203559c46666b6d1ee25e059175ba (diff)
parent37094685f47c050702a6fc2f9cdd9b6b06dccd90 (diff)
downloadprosody-333918c20296b46b7cd26a54cba1b4c3d51e5862.tar.gz
prosody-333918c20296b46b7cd26a54cba1b4c3d51e5862.zip
Merge 0.9->trunk
Diffstat (limited to 'prosodyctl')
-rwxr-xr-xprosodyctl34
1 files changed, 22 insertions, 12 deletions
diff --git a/prosodyctl b/prosodyctl
index 30a10b9a..247b099a 100755
--- a/prosodyctl
+++ b/prosodyctl
@@ -660,19 +660,29 @@ function cert_commands.config(arg)
end
local conf = openssl.config.new();
conf:from_prosody(hosts, config, arg);
- for k, v in pairs(conf.distinguished_name) do
- local nv;
- if k == "commonName" then
- v = arg[1]
- elseif k == "emailAddress" then
- v = "xmpp@" .. arg[1];
- 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"
+ 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
- conf.distinguished_name[k] = nv ~= "." and nv or nil;
end
local conf_file = io.open(conf_filename, "w");
conf_file:write(conf:serialize());