aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_tls.lua
diff options
context:
space:
mode:
authorJonas Schäfer <jonas@wielicki.name>2022-04-02 11:18:57 +0200
committerJonas Schäfer <jonas@wielicki.name>2022-04-02 11:18:57 +0200
commit87d3cb2f3348edf3753c487effd04e1af213f668 (patch)
treea9ffa1c09a85b79df724e318efc4604e122bb894 /plugins/mod_tls.lua
parent85abab1dfd0e1f919db3130bfd08226184099ac8 (diff)
downloadprosody-87d3cb2f3348edf3753c487effd04e1af213f668.tar.gz
prosody-87d3cb2f3348edf3753c487effd04e1af213f668.zip
mod_tls: tell network backend to stop reading while preparing TLS
Diffstat (limited to 'plugins/mod_tls.lua')
-rw-r--r--plugins/mod_tls.lua7
1 files changed, 7 insertions, 0 deletions
diff --git a/plugins/mod_tls.lua b/plugins/mod_tls.lua
index 76964082..dcb2da21 100644
--- a/plugins/mod_tls.lua
+++ b/plugins/mod_tls.lua
@@ -129,6 +129,13 @@ end);
module:hook("stanza/urn:ietf:params:xml:ns:xmpp-tls:starttls", function(event)
local origin = event.origin;
if can_do_tls(origin) then
+ if origin.conn.block_reads then
+ -- we need to ensure that no data is read anymore, otherwise we could end up in a situation where
+ -- <proceed/> is sent and the socket receives the TLS handshake (and passes the data to lua) before
+ -- it is asked to initiate TLS
+ -- (not with the classical single-threaded server backends)
+ origin.conn:block_reads()
+ end
(origin.sends2s or origin.send)(starttls_proceed);
if origin.destroyed then return end
origin:reset_stream();