Comparison

plugins/mod_tls.lua @ 3571:675d65036f31

certmanager, hostmanager, mod_tls: Move responsibility for creating per-host SSL contexts to mod_tls, meaning reloading certs is now as trivial as reloading mod_tls
author Matthew Wild <mwild1@gmail.com>
date Sat, 06 Nov 2010 18:28:15 +0000
parent 3397:f376f0bd1d1f
child 3574:1e088ec07d33
comparison
equal deleted inserted replaced
3570:6ef68af9431c 3571:675d65036f31
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 create_context = require "core.certmanager".create_context;
9 local st = require "util.stanza"; 10 local st = require "util.stanza";
10 11
11 local secure_auth_only = module:get_option("c2s_require_encryption") or module:get_option("require_encryption"); 12 local secure_auth_only = module:get_option("c2s_require_encryption") or module:get_option("require_encryption");
12 local secure_s2s_only = module:get_option("s2s_require_encryption"); 13 local secure_s2s_only = module:get_option("s2s_require_encryption");
13 local allow_s2s_tls = module:get_option("s2s_allow_encryption") ~= false; 14 local allow_s2s_tls = module:get_option("s2s_allow_encryption") ~= false;
85 local ssl_ctx = session.from_host and hosts[session.from_host].ssl_ctx or global_ssl_ctx; 86 local ssl_ctx = session.from_host and hosts[session.from_host].ssl_ctx or global_ssl_ctx;
86 session.conn:starttls(ssl_ctx); 87 session.conn:starttls(ssl_ctx);
87 session.secure = false; 88 session.secure = false;
88 return true; 89 return true;
89 end); 90 end);
91
92 function module.load()
93 local ssl_config = module:get_option("ssl");
94 host.ssl_ctx = create_context(host, "client", ssl_config); -- for outgoing connections
95 host.ssl_ctx_in = create_context(host, "server", ssl_config); -- for incoming connections
96 end
97
98 function module.unload()
99 host.ssl_ctx = nil;
100 host.ssl_ctx_in = nil;
101 end