diff options
author | Kim Alvefur <zash@zash.se> | 2017-09-27 15:21:20 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2017-09-27 15:21:20 +0200 |
commit | dc6396df0d9a765102bb429cef987aa2cb686769 (patch) | |
tree | 13d9c299f8183aef3ac1d8097454a6c15bee6d45 /prosodyctl | |
parent | dd09329efa034663518ca605849363e3e677e9f1 (diff) | |
download | prosody-dc6396df0d9a765102bb429cef987aa2cb686769.tar.gz prosody-dc6396df0d9a765102bb429cef987aa2cb686769.zip |
prosodyctl: cert import: Reuse function from certmanager for locating certificates and keys
Diffstat (limited to 'prosodyctl')
-rwxr-xr-x | prosodyctl | 14 |
1 files changed, 5 insertions, 9 deletions
@@ -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 |