Merge with trunk.
[prosody.git] / plugins / mod_tls.lua
index 15cdb3e3806bb39b9405295ffaa9e3e9e6805d08..90985874f0954a6b0b912d188ab455cb85081671 100644 (file)
@@ -18,7 +18,7 @@ local global_ssl_ctx = prosody.global_ssl_ctx;
 
 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;
@@ -27,8 +27,9 @@ module:hook("stanza/urn:ietf:params:xml:ns:xmpp-tls:starttls", function(event)
                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);