From eae8bd26c27278ea7a7b8bc015b93a3761750e89 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 22 Apr 2017 19:11:26 +0200 Subject: prosodyctl: Delay reporting of successful certificate imports until all done --- prosodyctl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'prosodyctl') diff --git a/prosodyctl b/prosodyctl index cc410f5a..e2f71223 100755 --- a/prosodyctl +++ b/prosodyctl @@ -873,18 +873,19 @@ function cert_commands.import(arg) owner = config.get("*", "prosody_user") or "prosody"; group = config.get("*", "prosody_group") or owner; end + 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); - show_message("Imported certificate and key for "..host); + 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); - show_message("Imported certificate and key for "..host); + table.insert(imported, host); else show_warning("No certificate for host "..host.." found :("); end @@ -893,6 +894,9 @@ function cert_commands.import(arg) -- Private key matches public key in certificate end end + if imported[1] then + show_message("Imported certificate and key for hosts "..table.concat(imported, ", ")); + end end function commands.cert(arg) -- cgit v1.2.3 From 934e6627ecf290b8428dea164e6c504623bee6f7 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 22 Apr 2017 19:12:04 +0200 Subject: prosodyctl: Return non-zero exit code from cert import if no certificates imported --- prosodyctl | 3 +++ 1 file changed, 3 insertions(+) (limited to 'prosodyctl') diff --git a/prosodyctl b/prosodyctl index e2f71223..4b29c406 100755 --- a/prosodyctl +++ b/prosodyctl @@ -896,6 +896,9 @@ function cert_commands.import(arg) end if imported[1] then show_message("Imported certificate and key for hosts "..table.concat(imported, ", ")); + else + show_warning("No certificates imported :("); + return 1; end end -- cgit v1.2.3 From dbb0ad8e7ed9dd71011d0c5f5203781cdf9566ad Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 22 Apr 2017 19:12:26 +0200 Subject: prosodyctl: Make note about reporting where certificates are searched for --- prosodyctl | 1 + 1 file changed, 1 insertion(+) (limited to 'prosodyctl') diff --git a/prosodyctl b/prosodyctl index 4b29c406..bee90665 100755 --- a/prosodyctl +++ b/prosodyctl @@ -887,6 +887,7 @@ function cert_commands.import(arg) copy(dir .. "/" .. host .. ".key", cert_basedir .. "/" .. host .. ".key", "0377", owner, group); table.insert(imported, host); else + -- TODO Say where we looked show_warning("No certificate for host "..host.." found :("); end -- TODO Additional checks -- cgit v1.2.3 From 04abad10a7f83c64a2bafdcb2888e9cad815f47d Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 22 Apr 2017 19:12:51 +0200 Subject: prosodyctl: Attempt to reload prosody after importing certificates --- prosodyctl | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'prosodyctl') diff --git a/prosodyctl b/prosodyctl index bee90665..dcc98a79 100755 --- a/prosodyctl +++ b/prosodyctl @@ -897,6 +897,10 @@ function cert_commands.import(arg) end if imported[1] then show_message("Imported certificate and key for hosts "..table.concat(imported, ", ")); + local ok, err = prosodyctl.reload(); + if not ok and err ~= "not-running" then + show_message(error_messages[err]); + end else show_warning("No certificates imported :("); return 1; -- cgit v1.2.3