sessionmanager, mod_tls: Mark a session as secure when TLS is active
authorMatthew Wild <mwild1@gmail.com>
Fri, 29 May 2009 13:28:53 +0000 (14:28 +0100)
committerMatthew Wild <mwild1@gmail.com>
Fri, 29 May 2009 13:28:53 +0000 (14:28 +0100)
core/sessionmanager.lua
plugins/mod_tls.lua

index 68493d87cb506e6cf90d6e2dad0839801ada87b6..07c44dfb230c2d53e87d768593676fcff8ce6f73 100644 (file)
@@ -171,6 +171,12 @@ function streamopened(session, attr)
                session:close{ condition = "host-unknown", text = "This server does not serve "..tostring(session.host)};
                return;
        end
+       
+       -- If session.secure is *false* (not nil) then it means we /were/ encrypting
+       -- since we now have a new stream header, session is secured
+       if session.secure == false then
+               session.secure = true;
+       end
                                                
        local features = st.stanza("stream:features");
        fire_event("stream-features", session, features);
index b382f318dea9b060722513645d4c57930904e9d1..85dc6bbabaec5028da04f58eee2d75d6d433e530 100644 (file)
@@ -19,6 +19,7 @@ module:add_handler("c2s_unauthed", "starttls", xmlns_starttls,
                                session:reset_stream();
                                session.conn.starttls();
                                session.log("info", "TLS negotiation started...");
+                               session.secure = false;
                        else
                                -- FIXME: What reply?
                                session.log("warn", "Attempt to start TLS, but TLS is not available on this connection");