# HG changeset patch
# User Kim Alvefur <zash@zash.se>
# Date 1621616641 -7200
# Node ID 9ad5ec65132df3b8b34ba01db2951f674f539d3c
# Parent  ec4f0ec3c0d571e079b4f4b0b50e86d9ade0c38a
mod_tls: Add "support" for <failure> by closing gracefully

Nicer than the "unsupported stanza type" error we get otherwise.

diff -r ec4f0ec3c0d5 -r 9ad5ec65132d plugins/mod_tls.lua
--- a/plugins/mod_tls.lua	Thu May 20 23:18:29 2021 +0200
+++ b/plugins/mod_tls.lua	Fri May 21 19:04:01 2021 +0200
@@ -174,3 +174,9 @@
 		return true;
 	end
 end);
+
+module:hook_tag(xmlns_starttls, "failure", function (session, stanza) -- luacheck: ignore 212/stanza
+	module:log("warn", "TLS negotiation with %s failed.", session.to_host);
+	session:close(nil, "TLS negotiation failed");
+	return false;
+end);