Software /
code /
prosody
Comparison
util/prosodyctl/cert.lua @ 12200:2bb4ee5f42be
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.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 19 Jan 2022 10:28:09 +0100 |
parent | 12199:12eaa2fdd75b |
child | 12216:0f5d04c3092f |
comparison
equal
deleted
inserted
replaced
12199:12eaa2fdd75b | 12200:2bb4ee5f42be |
---|---|
225 local paths = cm.find_cert_in_index(files_by_name, host); | 225 local paths = cm.find_cert_in_index(files_by_name, host); |
226 if paths and imported[paths.certificate] then | 226 if paths and imported[paths.certificate] then |
227 -- One certificate, many mames! | 227 -- One certificate, many mames! |
228 table.insert(imported, host); | 228 table.insert(imported, host); |
229 elseif paths then | 229 elseif paths then |
230 copy(paths.certificate, cert_basedir .. "/" .. host .. ".crt", nil, owner, group); | 230 local c = copy(paths.certificate, cert_basedir .. "/" .. host .. ".crt", nil, owner, group); |
231 copy(paths.key, cert_basedir .. "/" .. host .. ".key", "0377", owner, group); | 231 local k = copy(paths.key, cert_basedir .. "/" .. host .. ".key", "0377", owner, group); |
232 table.insert(imported, host); | 232 if c and k then |
233 imported[paths.certificate] = true; | 233 table.insert(imported, host); |
234 imported[paths.certificate] = true; | |
235 else | |
236 if not c then pctl.show_warning("Could not copy certificate '%s'", paths.certificate); end | |
237 if not k then pctl.show_warning("Could not copy key '%s'", paths.key); end | |
238 end | |
234 else | 239 else |
235 -- TODO Say where we looked | 240 -- TODO Say where we looked |
236 pctl.show_warning("No certificate for host %s found :(", host); | 241 pctl.show_warning("No certificate for host %s found :(", host); |
237 end | 242 end |
238 -- TODO Additional checks | 243 -- TODO Additional checks |