module:hook("stanza/urn:ietf:params:xml:ns:xmpp-tls:starttls", function(event)
local origin = event.origin;
- if origin.conn.starttls and origin.type == "c2s_unauthed" or origin.type == "s2sin_unauthed" then
+ if origin.conn.starttls then
(origin.sends2s or origin.send)(st.stanza("proceed", { xmlns = xmlns_starttls }));
origin:reset_stream();
local host = origin.to_host or origin.host;
origin.log("info", "TLS negotiation started for %s...", origin.type);
origin.secure = false;
else
- -- FIXME: What reply?
origin.log("warn", "Attempt to start TLS, but TLS is not available on this %s connection", origin.type);
+ (origin.sends2s or origin.send)(st.stanza("failure", { xmlns = xmlns_starttls }));
+ origin:close();
end
return true;
end);