+ local ssl_ctx, ssl_ctx_in;
+ if host and ssl then
+ -- We need to find SSL context to use...
+ -- Discussion in prosody@ concluded that
+ -- 1 level back is usually enough by default
+ local base_host = host:gsub("^[^%.]+%.", "");
+ if hosts[base_host] then
+ ssl_ctx = hosts[base_host].ssl_ctx;
+ ssl_ctx_in = hosts[base_host].ssl_ctx_in;
+ else
+ -- We have no cert, and no parent host to borrow a cert from
+ -- Use global/default cert if there is one
+ ssl_ctx = certmanager.create_context(host, "client");
+ ssl_ctx_in = certmanager.create_context(host, "server");
+ end
+ end
+ return { type = "component", host = host, connected = true, s2sout = {},
+ ssl_ctx = ssl_ctx, ssl_ctx_in = ssl_ctx_in, events = events or events_new(),
+ dialback_secret = configmanager.get(host, "core", "dialback_secret") or uuid_gen() };