Software /
code /
prosody
Comparison
core/componentmanager.lua @ 2629:fe207a2c5cef
componentmanager: Use certmanager for creating contexts
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 13 Feb 2010 16:10:01 +0000 |
parent | 2447:9eb539222f22 |
child | 2925:692b3c6c5bd2 |
comparison
equal
deleted
inserted
replaced
2628:04958fb28c44 | 2629:fe207a2c5cef |
---|---|
6 -- COPYING file in the source package for more information. | 6 -- COPYING file in the source package for more information. |
7 -- | 7 -- |
8 | 8 |
9 local prosody = _G.prosody; | 9 local prosody = _G.prosody; |
10 local log = require "util.logger".init("componentmanager"); | 10 local log = require "util.logger".init("componentmanager"); |
11 local certmanager = require "core.certmanager"; | |
11 local configmanager = require "core.configmanager"; | 12 local configmanager = require "core.configmanager"; |
12 local modulemanager = require "core.modulemanager"; | 13 local modulemanager = require "core.modulemanager"; |
13 local jid_split = require "util.jid".split; | 14 local jid_split = require "util.jid".split; |
14 local fire_event = require "core.eventmanager".fire_event; | 15 local fire_event = require "core.eventmanager".fire_event; |
15 local events_new = require "util.events".new; | 16 local events_new = require "util.events".new; |
82 -- 1 level back is usually enough by default | 83 -- 1 level back is usually enough by default |
83 local base_host = host:gsub("^[^%.]+%.", ""); | 84 local base_host = host:gsub("^[^%.]+%.", ""); |
84 if hosts[base_host] then | 85 if hosts[base_host] then |
85 ssl_ctx = hosts[base_host].ssl_ctx; | 86 ssl_ctx = hosts[base_host].ssl_ctx; |
86 ssl_ctx_in = hosts[base_host].ssl_ctx_in; | 87 ssl_ctx_in = hosts[base_host].ssl_ctx_in; |
87 elseif prosody.global_ssl_ctx then | 88 else |
88 -- We have no cert, and no parent host to borrow a cert from | 89 -- We have no cert, and no parent host to borrow a cert from |
89 -- Use global/default cert if there is one | 90 -- Use global/default cert if there is one |
90 ssl_ctx = ssl.newcontext(prosody.global_ssl_ctx); | 91 ssl_ctx = certmanager.create_context(host, "client"); |
91 ssl_ctx_in = ssl.newcontext(setmetatable({ mode = "server" }, { __index = prosody.global_ssl_ctx })); | 92 ssl_ctx_in = certmanager.create_context(host, "server"); |
92 end | 93 end |
93 end | 94 end |
94 return { type = "component", host = host, connected = true, s2sout = {}, | 95 return { type = "component", host = host, connected = true, s2sout = {}, |
95 ssl_ctx = ssl_ctx, ssl_ctx_in = ssl_ctx_in, events = events or events_new(), | 96 ssl_ctx = ssl_ctx, ssl_ctx_in = ssl_ctx_in, events = events or events_new(), |
96 dialback_secret = configmanager.get(host, "core", "dialback_secret") or uuid_gen() }; | 97 dialback_secret = configmanager.get(host, "core", "dialback_secret") or uuid_gen() }; |