comparison plugins/mod_tls.lua @ 7868:11fcdef5022f

Merge 0.10->trunk
author Kim Alvefur <zash@zash.se>
date Thu, 26 Jan 2017 19:47:33 +0100
parents 7ece186a44d3
children eb5fba4c8074
comparison
equal deleted inserted replaced
7861:58dbe5afeb4a 7868:11fcdef5022f
60 ssl_ctx_s2sin, err, ssl_cfg_s2sin = create_context(host.host, "server", host_s2s, host_ssl, global_s2s); -- for incoming server connections 60 ssl_ctx_s2sin, err, ssl_cfg_s2sin = create_context(host.host, "server", host_s2s, host_ssl, global_s2s); -- for incoming server connections
61 if not ssl_ctx_s2sin then module:log("error", "Error creating contexts for s2sin: %s", err); end 61 if not ssl_ctx_s2sin then module:log("error", "Error creating contexts for s2sin: %s", err); end
62 end 62 end
63 63
64 local function can_do_tls(session) 64 local function can_do_tls(session)
65 if session.ssl_ctx == false or not session.conn.starttls then 65 if session.ssl_ctx ~= nil then
66 return session.ssl_ctx;
67 elseif not session.conn.starttls then
66 return false; 68 return false;
67 elseif session.ssl_ctx then
68 return true;
69 end 69 end
70 if session.type == "c2s_unauthed" then 70 if session.type == "c2s_unauthed" then
71 session.ssl_ctx = ssl_ctx_c2s; 71 session.ssl_ctx = ssl_ctx_c2s;
72 session.ssl_cfg = ssl_cfg_c2s; 72 session.ssl_cfg = ssl_cfg_c2s;
73 elseif session.type == "s2sin_unauthed" and allow_s2s_tls then 73 elseif session.type == "s2sin_unauthed" and allow_s2s_tls then
75 session.ssl_cfg = ssl_cfg_s2sin; 75 session.ssl_cfg = ssl_cfg_s2sin;
76 elseif session.direction == "outgoing" and allow_s2s_tls then 76 elseif session.direction == "outgoing" and allow_s2s_tls then
77 session.ssl_ctx = ssl_ctx_s2sout; 77 session.ssl_ctx = ssl_ctx_s2sout;
78 session.ssl_cfg = ssl_cfg_s2sout; 78 session.ssl_cfg = ssl_cfg_s2sout;
79 else 79 else
80 return false;
81 end
82 if not session.ssl_ctx then
83 session.log("debug", "Should be able to do TLS but no context available");
80 return false; 84 return false;
81 end 85 end
82 return session.ssl_ctx; 86 return session.ssl_ctx;
83 end 87 end
84 88