Comparison

plugins/mod_tls.lua @ 6832:9566a15d3e59

mod_tls: Fix inhertinance of 'ssl' option from "parent" host to subdomain (fixes #511)
author Kim Alvefur <zash@zash.se>
date Tue, 15 Sep 2015 17:51:56 +0200
parent 6710:d062314446f6
child 6918:de35feccc78e
comparison
equal deleted inserted replaced
6831:428b8da1cfce 6832:9566a15d3e59
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 create_context = require "core.certmanager".create_context;
10 local rawgetopt = require"core.configmanager".rawget;
10 local st = require "util.stanza"; 11 local st = require "util.stanza";
11 12
12 local c2s_require_encryption = module:get_option("c2s_require_encryption", module:get_option("require_encryption")); 13 local c2s_require_encryption = module:get_option("c2s_require_encryption", module:get_option("require_encryption"));
13 local s2s_require_encryption = module:get_option("s2s_require_encryption"); 14 local s2s_require_encryption = module:get_option("s2s_require_encryption");
14 local allow_s2s_tls = module:get_option("s2s_allow_encryption") ~= false; 15 local allow_s2s_tls = module:get_option("s2s_allow_encryption") ~= false;
34 35
35 local ssl_ctx_c2s, ssl_ctx_s2sout, ssl_ctx_s2sin; 36 local ssl_ctx_c2s, ssl_ctx_s2sout, ssl_ctx_s2sin;
36 local ssl_cfg_c2s, ssl_cfg_s2sout, ssl_cfg_s2sin; 37 local ssl_cfg_c2s, ssl_cfg_s2sout, ssl_cfg_s2sin;
37 do 38 do
38 local NULL, err = {}; 39 local NULL, err = {};
39 local global = module:context("*"); 40 local modhost = module.host;
40 local parent = module:context(module.host:match("%.(.*)$")); 41 local parent = modhost:match("%.(.*)$");
41 42
42 local parent_ssl = parent:get_option("ssl"); 43 local global_ssl = rawgetopt("*", "ssl") or NULL;
43 local host_ssl = module:get_option("ssl", parent_ssl); 44 local parent_ssl = rawgetopt(parent, "ssl") or NULL;
45 local host_ssl = rawgetopt(modhost, "ssl") or parent_ssl;
44 46
45 local global_c2s = global:get_option("c2s_ssl", NULL); 47 local global_c2s = rawgetopt("*", "c2s_ssl") or NULL;
46 local parent_c2s = parent:get_option("c2s_ssl", NULL); 48 local parent_c2s = rawgetopt(parent, "c2s_ssl") or NULL;
47 local host_c2s = module:get_option("c2s_ssl", parent_c2s); 49 local host_c2s = rawgetopt(modhost, "c2s_ssl") or parent_ssl;
48 50
49 local global_s2s = global:get_option("s2s_ssl", NULL); 51 local global_s2s = rawgetopt("*", "s2s_ssl") or NULL;
50 local parent_s2s = parent:get_option("s2s_ssl", NULL); 52 local parent_s2s = rawgetopt(parent, "s2s_ssl") or NULL;
51 local host_s2s = module:get_option("s2s_ssl", parent_s2s); 53 local host_s2s = rawgetopt(modhost, "s2s_ssl") or parent_ssl;
52 54
53 ssl_ctx_c2s, err, ssl_cfg_c2s = create_context(host.host, "server", host_c2s, host_ssl, global_c2s); -- for incoming client connections 55 ssl_ctx_c2s, err, ssl_cfg_c2s = create_context(host.host, "server", host_c2s, host_ssl, global_c2s); -- for incoming client connections
54 if not ssl_ctx_c2s then module:log("error", "Error creating context for c2s: %s", err); end 56 if not ssl_ctx_c2s then module:log("error", "Error creating context for c2s: %s", err); end
55 57
56 ssl_ctx_s2sout, err, ssl_cfg_s2sout = create_context(host.host, "client", host_s2s, host_ssl, global_s2s); -- for outgoing server connections 58 ssl_ctx_s2sout, err, ssl_cfg_s2sout = create_context(host.host, "client", host_s2s, host_ssl, global_s2s); -- for outgoing server connections