1 local st = require "util.stanza"; |
|
2 local xmlns_tls = "urn:ietf:params:xml:ns:xmpp-tls"; |
1 local xmlns_tls = "urn:ietf:params:xml:ns:xmpp-tls"; |
3 |
2 |
4 function verse.plugins.tls(stream) |
3 function verse.plugins.tls(stream) |
5 local function handle_features(features_stanza) |
4 local function handle_features(features_stanza) |
6 if stream.authenticated then return; end |
5 if stream.authenticated then return; end |
7 if features_stanza:get_child("starttls", xmlns_tls) and stream.conn.starttls then |
6 if features_stanza:get_child("starttls", xmlns_tls) and stream.conn.starttls then |
8 stream:debug("Negotiating TLS..."); |
7 stream:debug("Negotiating TLS..."); |
9 stream:send(st.stanza("starttls", { xmlns = xmlns_tls })); |
8 stream:send(verse.stanza("starttls", { xmlns = xmlns_tls })); |
10 return true; |
9 return true; |
11 elseif not stream.conn.starttls and not stream.secure then |
10 elseif not stream.conn.starttls and not stream.secure then |
12 stream:warn("SSL libary (LuaSec) not loaded, so TLS not available"); |
11 stream:warn("SSL libary (LuaSec) not loaded, so TLS not available"); |
13 elseif not stream.secure then |
12 elseif not stream.secure then |
14 stream:debug("Server doesn't offer TLS :("); |
13 stream:debug("Server doesn't offer TLS :("); |