Mercurial > prosody-hg
comparison util/openssl.lua @ 7023:c2ccbfe30113
util.openssl: Fix style / whitespace
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Wed, 23 Dec 2015 08:47:57 +0100 |
| parents | 3252c107c91a |
| children | 18a13a7b4bac |
comparison
equal
deleted
inserted
replaced
| 7022:3252c107c91a | 7023:c2ccbfe30113 |
|---|---|
| 10 local _M = {}; | 10 local _M = {}; |
| 11 local config = {}; | 11 local config = {}; |
| 12 _M.config = config; | 12 _M.config = config; |
| 13 | 13 |
| 14 local ssl_config = {}; | 14 local ssl_config = {}; |
| 15 local ssl_config_mt = {__index=ssl_config}; | 15 local ssl_config_mt = { __index = ssl_config }; |
| 16 | 16 |
| 17 function config.new() | 17 function config.new() |
| 18 return setmetatable({ | 18 return setmetatable({ |
| 19 req = { | 19 req = { |
| 20 distinguished_name = "distinguished_name", | 20 distinguished_name = "distinguished_name", |
| 63 local s = ""; | 63 local s = ""; |
| 64 for k, t in pairs(self) do | 64 for k, t in pairs(self) do |
| 65 s = s .. ("[%s]\n"):format(k); | 65 s = s .. ("[%s]\n"):format(k); |
| 66 if k == "subject_alternative_name" then | 66 if k == "subject_alternative_name" then |
| 67 for san, n in pairs(t) do | 67 for san, n in pairs(t) do |
| 68 for i = 1,#n do | 68 for i = 1, #n do |
| 69 s = s .. s_format("%s.%d = %s\n", san, i -1, n[i]); | 69 s = s .. s_format("%s.%d = %s\n", san, i -1, n[i]); |
| 70 end | 70 end |
| 71 end | 71 end |
| 72 elseif k == "distinguished_name" then | 72 elseif k == "distinguished_name" then |
| 73 for i=1,#DN_order do | 73 for i=1, #DN_order do |
| 74 local k = DN_order[i] | 74 local k = DN_order[i] |
| 75 local v = t[k]; | 75 local v = t[k]; |
| 76 if v then | 76 if v then |
| 77 s = s .. ("%s = %s\n"):format(k, v); | 77 s = s .. ("%s = %s\n"):format(k, v); |
| 78 end | 78 end |
| 105 t_insert(self.subject_alternative_name.DNS, idna_to_ascii(host)); | 105 t_insert(self.subject_alternative_name.DNS, idna_to_ascii(host)); |
| 106 end | 106 end |
| 107 | 107 |
| 108 function ssl_config:add_sRVName(host, service) | 108 function ssl_config:add_sRVName(host, service) |
| 109 t_insert(self.subject_alternative_name.otherName, | 109 t_insert(self.subject_alternative_name.otherName, |
| 110 s_format("%s;%s", oid_dnssrv, ia5string("_" .. service .."." .. idna_to_ascii(host)))); | 110 s_format("%s;%s", oid_dnssrv, ia5string("_" .. service .. "." .. idna_to_ascii(host)))); |
| 111 end | 111 end |
| 112 | 112 |
| 113 function ssl_config:add_xmppAddr(host) | 113 function ssl_config:add_xmppAddr(host) |
| 114 t_insert(self.subject_alternative_name.otherName, | 114 t_insert(self.subject_alternative_name.otherName, |
| 115 s_format("%s;%s", oid_xmppaddr, utf8string(host))); | 115 s_format("%s;%s", oid_xmppaddr, utf8string(host))); |
| 116 end | 116 end |
| 117 | 117 |
| 118 function ssl_config:from_prosody(hosts, config, certhosts) | 118 function ssl_config:from_prosody(hosts, config, certhosts) |
| 119 -- TODO Decide if this should go elsewhere | 119 -- TODO Decide if this should go elsewhere |
| 120 local found_matching_hosts = false; | 120 local found_matching_hosts = false; |
| 121 for i = 1,#certhosts do | 121 for i = 1, #certhosts do |
| 122 local certhost = certhosts[i]; | 122 local certhost = certhosts[i]; |
| 123 for name in pairs(hosts) do | 123 for name in pairs(hosts) do |
| 124 if name == certhost or name:sub(-1-#certhost) == "."..certhost then | 124 if name == certhost or name:sub(-1-#certhost) == "." .. certhost then |
| 125 found_matching_hosts = true; | 125 found_matching_hosts = true; |
| 126 self:add_dNSName(name); | 126 self:add_dNSName(name); |
| 127 --print(name .. "#component_module: " .. (config.get(name, "component_module") or "nil")); | 127 --print(name .. "#component_module: " .. (config.get(name, "component_module") or "nil")); |
| 128 if config.get(name, "component_module") == nil then | 128 if config.get(name, "component_module") == nil then |
| 129 self:add_sRVName(name, "xmpp-client"); | 129 self:add_sRVName(name, "xmpp-client"); |
| 163 return t_concat(commandline, " "); | 163 return t_concat(commandline, " "); |
| 164 end | 164 end |
| 165 | 165 |
| 166 local os_execute = os.execute; | 166 local os_execute = os.execute; |
| 167 setmetatable(_M, { | 167 setmetatable(_M, { |
| 168 __index=function(_,f) | 168 __index = function(_, command) |
| 169 return function(opts) | 169 return function(opts) |
| 170 return 0 == os_execute(serialize(command, type(opts) == "table" and opts or {})); | 170 return 0 == os_execute(serialize(command, type(opts) == "table" and opts or {})); |
| 171 end; | 171 end; |
| 172 end; | 172 end; |
| 173 }); | 173 }); |
