Software /
code /
prosody
Changeset
7195:39b7ea9141c0
Merge 0.10->trunk
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 25 Feb 2016 15:40:35 +0100 |
parents | 7191:df4f52cabdfe (current diff) 7194:1c55403d06c4 (diff) |
children | 7207:14ea924a036d |
files | prosodyctl |
diffstat | 3 files changed, 38 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/certs/Makefile Wed Feb 24 11:20:00 2016 +0100 +++ b/certs/Makefile Thu Feb 25 15:40:35 2016 +0100 @@ -60,3 +60,7 @@ %.key: umask 0077 && openssl genrsa -out $@ $(keysize) @chmod 400 $@ -c + +# Generate Diffie-Hellman parameters +dh-%.pem: + openssl dhparam -out $@ $*
--- a/prosodyctl Wed Feb 24 11:20:00 2016 +0100 +++ b/prosodyctl Thu Feb 25 15:40:35 2016 +0100 @@ -698,30 +698,43 @@ 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");
--- a/util/openssl.lua Wed Feb 24 11:20:00 2016 +0100 +++ b/util/openssl.lua Thu Feb 25 15:40:35 2016 +0100 @@ -70,8 +70,7 @@ end end elseif k == "distinguished_name" then - for i=1, #DN_order do - local k = DN_order[i] + for i, k in ipairs(t[1] and t or DN_order) do local v = t[k]; if v then s = s .. ("%s = %s\n"):format(k, v);