# HG changeset patch
# User Waqas Hussain <waqas20@gmail.com>
# Date 1265924390 -18000
# Node ID 91143b35a7555a8fea887a088bb269aa7fc5cdd9
# Parent  56630a6c9a3107a8044dff0c191aaa4b058a738d
mod_tls: Respond with proper error when TLS cannot be negotiated.

diff -r 56630a6c9a31 -r 91143b35a755 plugins/mod_tls.lua
--- a/plugins/mod_tls.lua	Fri Feb 12 00:55:06 2010 +0500
+++ b/plugins/mod_tls.lua	Fri Feb 12 02:39:50 2010 +0500
@@ -26,8 +26,9 @@
 				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");
+				(session.sends2s or session.send)(st.stanza("failure", { xmlns = xmlns_starttls }));
+				session:close();
 			end
 		end);
 		
@@ -43,8 +44,9 @@
 				session.log("info", "TLS negotiation started for incoming s2s...");
 				session.secure = false;
 			else
-				-- FIXME: What reply?
 				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);