Comparison

plugins/tls.lua @ 63:311e61176159

verse.plugins.tls: Fail gracefully when LuaSec not loaded
author Matthew Wild <mwild1@gmail.com>
date Tue, 11 May 2010 23:06:52 +0100
parent 61:6adddfdf974b
child 65:4f13cc5f96b0
comparison
equal deleted inserted replaced
62:d4b6f9e33c6e 63:311e61176159
2 local xmlns_tls = "urn:ietf:params:xml:ns:xmpp-tls"; 2 local xmlns_tls = "urn:ietf:params:xml:ns:xmpp-tls";
3 3
4 function verse.plugins.tls(stream) 4 function verse.plugins.tls(stream)
5 local function handle_features(features_stanza) 5 local function handle_features(features_stanza)
6 if stream.authenticated then return; end 6 if stream.authenticated then return; end
7 if features_stanza:get_child("starttls", xmlns_tls) then 7 if features_stanza:get_child("starttls", xmlns_tls) and stream.conn.starttls then
8 stream:debug("Negotiating TLS..."); 8 stream:debug("Negotiating TLS...");
9 stream:send(st.stanza("starttls", { xmlns = xmlns_tls })); 9 stream:send(st.stanza("starttls", { xmlns = xmlns_tls }));
10 return true; 10 return true;
11 elseif not stream.conn.starttls then
12 stream:warn("SSL libary (LuaSec) not loaded, so TLS not available");
11 else 13 else
12 stream:debug("Server doesn't offer TLS :("); 14 stream:debug("Server doesn't offer TLS :(");
13 end 15 end
14 end 16 end
15 local function handle_tls(tls_status) 17 local function handle_tls(tls_status)