# HG changeset patch # User Kim Alvefur # Date 1642584489 -3600 # Node ID 2bb4ee5f42bed1824ef3355c39cff5c1024fd78e # Parent 12eaa2fdd75b969aba5d6ef8b09e0b8c0b823a51 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. diff -r 12eaa2fdd75b -r 2bb4ee5f42be util/prosodyctl/cert.lua --- a/util/prosodyctl/cert.lua Wed Jan 19 10:26:43 2022 +0100 +++ b/util/prosodyctl/cert.lua Wed Jan 19 10:28:09 2022 +0100 @@ -227,10 +227,15 @@ -- 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);