-module:add_handler("c2s_unauthed", "starttls", xmlns_starttls,
- function (session, stanza)
- if session.conn.starttls and host.ssl_ctx_in then
- session.send(st.stanza("proceed", { xmlns = xmlns_starttls }));
- session:reset_stream();
- if session.host and hosts[session.host].ssl_ctx_in then
- session.conn.set_sslctx(hosts[session.host].ssl_ctx_in);
- end
- session.conn.starttls();
- session.log("info", "TLS negotiation started...");
- session.secure = false;
- else
- session.log("warn", "Attempt to start TLS, but TLS is not available on this connection");
- (session.sends2s or session.send)(st.stanza("failure", { xmlns = xmlns_starttls }));
- session:close();
- end
- end);
-
-module:add_handler("s2sin_unauthed", "starttls", xmlns_starttls,
- function (session, stanza)
- if session.conn.starttls and host.ssl_ctx_in then
- session.sends2s(st.stanza("proceed", { xmlns = xmlns_starttls }));
- session:reset_stream();
- if session.to_host and hosts[session.to_host].ssl_ctx_in then
- session.conn.set_sslctx(hosts[session.to_host].ssl_ctx_in);
- end
- session.conn.starttls();
- session.log("info", "TLS negotiation started for incoming s2s...");
- session.secure = false;
- else
- session.log("warn", "Attempt to start TLS, but TLS is not available on this s2s connection");
- (session.sends2s or session.send)(st.stanza("failure", { xmlns = xmlns_starttls }));
- session:close();
- end
- end);