Comparison

core/hostmanager.lua @ 1893:2d202336c9b6

hostmanager: Create ssl context for each host (fixes #30 for outgoing s2s connections)
author Matthew Wild <mwild1@gmail.com>
date Sun, 04 Oct 2009 16:50:22 +0100
parent 1848:0033359aeb70
child 1925:6897bd311afa
comparison
equal deleted inserted replaced
1892:adc0c80413ee 1893:2d202336c9b6
4 -- 4 --
5 -- This project is MIT/X11 licensed. Please see the 5 -- This project is MIT/X11 licensed. Please see the
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 ssl = ssl
9 10
10 local hosts = hosts; 11 local hosts = hosts;
11 local configmanager = require "core.configmanager"; 12 local configmanager = require "core.configmanager";
12 local eventmanager = require "core.eventmanager"; 13 local eventmanager = require "core.eventmanager";
13 local events_new = require "util.events".new; 14 local events_new = require "util.events".new;
14 15
16 -- These are the defaults if not overridden in the config
17 local default_ssl_ctx = { mode = "client", protocol = "sslv23", capath = "/etc/ssl/certs", verify = "none"; };
18
15 local log = require "util.logger".init("hostmanager"); 19 local log = require "util.logger".init("hostmanager");
16 20
17 local pairs = pairs; 21 local pairs, setmetatable = pairs, setmetatable;
18 22
19 module "hostmanager" 23 module "hostmanager"
20 24
21 local hosts_loaded_once; 25 local hosts_loaded_once;
22 26
44 for option_name in pairs(host_config.core) do 48 for option_name in pairs(host_config.core) do
45 if option_name:match("_ports$") then 49 if option_name:match("_ports$") then
46 log("warn", "%s: Option '%s' has no effect for virtual hosts - put it in global Host \"*\" instead", host, option_name); 50 log("warn", "%s: Option '%s' has no effect for virtual hosts - put it in global Host \"*\" instead", host, option_name);
47 end 51 end
48 end 52 end
53
54 local ssl_config = host_config.core.ssl or configmanager.get("*", "core", "ssl");
55 if ssl_config then
56 hosts[host].ssl_ctx = ssl.newcontext(setmetatable(ssl_config, { __index = default_ssl_ctx }));
57 end
58
49 log((hosts_loaded_once and "info") or "debug", "Activated host: %s", host); 59 log((hosts_loaded_once and "info") or "debug", "Activated host: %s", host);
50 eventmanager.fire_event("host-activated", host, host_config); 60 eventmanager.fire_event("host-activated", host, host_config);
51 end 61 end
52 62
53 function deactivate(host) 63 function deactivate(host)