diff options
author | Kim Alvefur <zash@zash.se> | 2022-01-19 10:28:09 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2022-01-19 10:28:09 +0100 |
commit | 41e0ddd7910240fba9feec42c205d7a2506ac971 (patch) | |
tree | 2d0f006358bc32c4047bd668ebce59a01910052c /util | |
parent | 2a1f14fc26ce3ad4e5acc29bd2a5a2aeb6b0e7b0 (diff) | |
download | prosody-41e0ddd7910240fba9feec42c205d7a2506ac971.tar.gz prosody-41e0ddd7910240fba9feec42c205d7a2506ac971.zip |
util.prosodyctl.cert: Check success of copy operations, warn on fail
Debugging a case where certs are not imported correctly but prosodyctl
still reports success. Hoping this will shed some light on it.
Diffstat (limited to 'util')
-rw-r--r-- | util/prosodyctl/cert.lua | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/util/prosodyctl/cert.lua b/util/prosodyctl/cert.lua index 42f529ca..236fc99e 100644 --- a/util/prosodyctl/cert.lua +++ b/util/prosodyctl/cert.lua @@ -227,10 +227,15 @@ function cert_commands.import(arg) -- One certificate, many mames! table.insert(imported, host); elseif 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); - imported[paths.certificate] = true; + local c = copy(paths.certificate, cert_basedir .. "/" .. host .. ".crt", nil, owner, group); + local k = copy(paths.key, cert_basedir .. "/" .. host .. ".key", "0377", owner, group); + if c and k then + table.insert(imported, host); + imported[paths.certificate] = true; + else + if not c then pctl.show_warning("Could not copy certificate '%s'", paths.certificate); end + if not k then pctl.show_warning("Could not copy key '%s'", paths.key); end + end else -- TODO Say where we looked pctl.show_warning("No certificate for host %s found :(", host); |