s2smanager: Make require_s2s_encryption do what it says on the tin

Sat, 30 Jan 2010 16:42:27 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Sat, 30 Jan 2010 16:42:27 +0000
changeset 2799
0dc7b5ceaf8f
parent 2798
2702ee68727d
child 2800
5880c621f082

s2smanager: Make require_s2s_encryption do what it says on the tin

core/s2smanager.lua file | annotate | diff | comparison | revisions
--- a/core/s2smanager.lua	Wed Mar 03 20:12:24 2010 +0000
+++ b/core/s2smanager.lua	Sat Jan 30 16:42:27 2010 +0000
@@ -449,6 +449,16 @@
 end
 
 function make_authenticated(session, host)
+	if not session.secure then
+		local local_host = session.direction == "incoming" and session.to_host or session.from_host;
+		if config.get(local_host, "core", "require_s2s_encryption")) then
+			session:close({
+				condition = "policy-violation",
+				text = "Encrypted server-to-server communication is required but was not "
+				       ..((session.direction == "outgoing" and "offered") or "used")
+			});
+		end
+	end
 	if session.type == "s2sout_unauthed" then
 		session.type = "s2sout";
 	elseif session.type == "s2sin_unauthed" then

mercurial