Comparison

plugins/mod_tls.lua @ 2654:07a6f5f9d4be

mod_tls: Only negotiate TLS on outgoing s2s connections if we have an SSL context (thanks Flo...)
author Matthew Wild <mwild1@gmail.com>
date Tue, 16 Feb 2010 17:15:43 +0000
parent 2636:d2805ad5b736
child 2925:692b3c6c5bd2
comparison
equal deleted inserted replaced
2652:cbc58fc170ad 2654:07a6f5f9d4be
27 local function can_do_tls(session) 27 local function can_do_tls(session)
28 if session.type == "c2s_unauthed" then 28 if session.type == "c2s_unauthed" then
29 return session.conn.starttls and host.ssl_ctx_in; 29 return session.conn.starttls and host.ssl_ctx_in;
30 elseif session.type == "s2sin_unauthed" then 30 elseif session.type == "s2sin_unauthed" then
31 return session.conn.starttls and host.ssl_ctx_in; 31 return session.conn.starttls and host.ssl_ctx_in;
32 elseif session.direction == "outgoing" then
33 return session.conn.starttls and host.ssl_ctx;
32 end 34 end
33 return false; 35 return false;
34 end 36 end
35 37
36 -- Hook <starttls/> 38 -- Hook <starttls/>
67 end); 69 end);
68 70
69 -- For s2sout connections, start TLS if we can 71 -- For s2sout connections, start TLS if we can
70 module:hook_stanza("http://etherx.jabber.org/streams", "features", function (session, stanza) 72 module:hook_stanza("http://etherx.jabber.org/streams", "features", function (session, stanza)
71 module:log("debug", "Received features element"); 73 module:log("debug", "Received features element");
72 if session.conn.starttls and stanza:child_with_ns(xmlns_starttls) then 74 if can_do_tls(session) and stanza:child_with_ns(xmlns_starttls) then
73 module:log("%s is offering TLS, taking up the offer...", session.to_host); 75 module:log("%s is offering TLS, taking up the offer...", session.to_host);
74 session.sends2s("<starttls xmlns='"..xmlns_starttls.."'/>"); 76 session.sends2s("<starttls xmlns='"..xmlns_starttls.."'/>");
75 return true; 77 return true;
76 end 78 end
77 end, 500); 79 end, 500);