2 local st = require "util.stanza";
3 local send = require "core.sessionmanager".send_to_session;
5 --local sessions = sessions;
7 local t_insert = table.insert;
9 local log = require "util.logger".init("mod_starttls");
11 local xmlns_starttls ='urn:ietf:params:xml:ns:xmpp-tls';
13 add_handler("c2s_unauthed", "starttls", xmlns_starttls,
14 function (session, stanza)
15 if session.conn.starttls then
16 send(session, st.stanza("proceed", { xmlns = xmlns_starttls }));
17 -- FIXME: I'm commenting the below, not sure why it was necessary
18 -- sessions[session.conn] = nil;
19 session:reset_stream();
20 session.conn.starttls();
21 session.log("info", "TLS negotiation started...");
24 session.log("warn", "Attempt to start TLS, but TLS is not available on this connection");
28 add_event_hook("stream-features",
29 function (session, features)
30 if session.conn.starttls then
31 t_insert(features, "<starttls xmlns='"..xmlns_starttls.."'/>");