aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2017-09-27 15:21:20 +0200
committerKim Alvefur <zash@zash.se>2017-09-27 15:21:20 +0200
commite24b2b1208fb1678e9bf0bdc394786f00563051e (patch)
tree13d9c299f8183aef3ac1d8097454a6c15bee6d45
parent40c69827f0806ee592694d6cf92180866d2f9369 (diff)
downloadprosody-e24b2b1208fb1678e9bf0bdc394786f00563051e.tar.gz
prosody-e24b2b1208fb1678e9bf0bdc394786f00563051e.zip
prosodyctl: cert import: Reuse function from certmanager for locating certificates and keys
-rw-r--r--core/certmanager.lua1
-rwxr-xr-xprosodyctl14
2 files changed, 6 insertions, 9 deletions
diff --git a/core/certmanager.lua b/core/certmanager.lua
index 288836ce..73b346c3 100644
--- a/core/certmanager.lua
+++ b/core/certmanager.lua
@@ -231,4 +231,5 @@ prosody.events.add_handler("config-reloaded", reload_ssl_config);
return {
create_context = create_context;
reload_ssl_config = reload_ssl_config;
+ find_cert = find_cert;
};
diff --git a/prosodyctl b/prosodyctl
index 311f251e..3323b169 100755
--- a/prosodyctl
+++ b/prosodyctl
@@ -894,18 +894,14 @@ function cert_commands.import(arg)
owner = config.get("*", "prosody_user") or "prosody";
group = config.get("*", "prosody_group") or owner;
end
+ local cm = require "core.certmanager";
local imported = {};
for _, host in ipairs(hostnames) do
for _, dir in ipairs(arg) do
- if lfs.attributes(dir .. "/" .. host .. "/fullchain.pem")
- and lfs.attributes(dir .. "/" .. host .. "/privkey.pem") then
- copy(dir .. "/" .. host .. "/fullchain.pem", cert_basedir .. "/" .. host .. ".crt", nil, owner, group);
- copy(dir .. "/" .. host .. "/privkey.pem", cert_basedir .. "/" .. host .. ".key", "0377", owner, group);
- table.insert(imported, host);
- elseif lfs.attributes(dir .. "/" .. host .. ".crt")
- and lfs.attributes(dir .. "/" .. host .. ".key") then
- copy(dir .. "/" .. host .. ".crt", cert_basedir .. "/" .. host .. ".crt", nil, owner, group);
- copy(dir .. "/" .. host .. ".key", cert_basedir .. "/" .. host .. ".key", "0377", owner, group);
+ local paths = cm.find_cert(dir, host);
+ if paths then
+ copy(paths.certificate, cert_basedir .. "/" .. host .. ".crt", nil, owner, group);
+ copy(paths.key, cert_basedir .. "/" .. host .. ".key", "0377", owner, group);
table.insert(imported, host);
else
-- TODO Say where we looked