Software /
code /
prosody
Comparison
prosodyctl @ 8121:a33a87f13155
Merge 0.10->trunk
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 24 Apr 2017 14:19:49 +0200 |
parent | 8112:d8ecefcb7c97 |
parent | 8120:3c5f0cb4381a |
child | 8128:c14513401d65 |
comparison
equal
deleted
inserted
replaced
8112:d8ecefcb7c97 | 8121:a33a87f13155 |
---|---|
871 local owner, group; | 871 local owner, group; |
872 if pposix.getuid() == 0 then -- We need root to change ownership | 872 if pposix.getuid() == 0 then -- We need root to change ownership |
873 owner = config.get("*", "prosody_user") or "prosody"; | 873 owner = config.get("*", "prosody_user") or "prosody"; |
874 group = config.get("*", "prosody_group") or owner; | 874 group = config.get("*", "prosody_group") or owner; |
875 end | 875 end |
876 local imported = {}; | |
876 for _, host in ipairs(hostnames) do | 877 for _, host in ipairs(hostnames) do |
877 for _, dir in ipairs(arg) do | 878 for _, dir in ipairs(arg) do |
878 if lfs.attributes(dir .. "/" .. host .. "/fullchain.pem") | 879 if lfs.attributes(dir .. "/" .. host .. "/fullchain.pem") |
879 and lfs.attributes(dir .. "/" .. host .. "/privkey.pem") then | 880 and lfs.attributes(dir .. "/" .. host .. "/privkey.pem") then |
880 copy(dir .. "/" .. host .. "/fullchain.pem", cert_basedir .. "/" .. host .. ".crt", nil, owner, group); | 881 copy(dir .. "/" .. host .. "/fullchain.pem", cert_basedir .. "/" .. host .. ".crt", nil, owner, group); |
881 copy(dir .. "/" .. host .. "/privkey.pem", cert_basedir .. "/" .. host .. ".key", "0377", owner, group); | 882 copy(dir .. "/" .. host .. "/privkey.pem", cert_basedir .. "/" .. host .. ".key", "0377", owner, group); |
882 show_message("Imported certificate and key for "..host); | 883 table.insert(imported, host); |
883 elseif lfs.attributes(dir .. "/" .. host .. ".crt") | 884 elseif lfs.attributes(dir .. "/" .. host .. ".crt") |
884 and lfs.attributes(dir .. "/" .. host .. ".key") then | 885 and lfs.attributes(dir .. "/" .. host .. ".key") then |
885 copy(dir .. "/" .. host .. ".crt", cert_basedir .. "/" .. host .. ".crt", nil, owner, group); | 886 copy(dir .. "/" .. host .. ".crt", cert_basedir .. "/" .. host .. ".crt", nil, owner, group); |
886 copy(dir .. "/" .. host .. ".key", cert_basedir .. "/" .. host .. ".key", "0377", owner, group); | 887 copy(dir .. "/" .. host .. ".key", cert_basedir .. "/" .. host .. ".key", "0377", owner, group); |
887 show_message("Imported certificate and key for "..host); | 888 table.insert(imported, host); |
888 else | 889 else |
890 -- TODO Say where we looked | |
889 show_warning("No certificate for host "..host.." found :("); | 891 show_warning("No certificate for host "..host.." found :("); |
890 end | 892 end |
891 -- TODO Additional checks | 893 -- TODO Additional checks |
892 -- Certificate names matches the hostname | 894 -- Certificate names matches the hostname |
893 -- Private key matches public key in certificate | 895 -- Private key matches public key in certificate |
894 end | 896 end |
897 end | |
898 if imported[1] then | |
899 show_message("Imported certificate and key for hosts "..table.concat(imported, ", ")); | |
900 local ok, err = prosodyctl.reload(); | |
901 if not ok and err ~= "not-running" then | |
902 show_message(error_messages[err]); | |
903 end | |
904 else | |
905 show_warning("No certificates imported :("); | |
906 return 1; | |
895 end | 907 end |
896 end | 908 end |
897 | 909 |
898 function commands.cert(arg) | 910 function commands.cert(arg) |
899 if #arg >= 1 and arg[1] ~= "--help" then | 911 if #arg >= 1 and arg[1] ~= "--help" then |