From: Rob Rozestraten via pve-devel <pve-devel@lists.proxmox.com>
To: pve-devel@lists.proxmox.com
Cc: Rob Rozestraten <admin@truthsolo.net>
Subject: [pve-devel] [PATCH pve-http-server v2 1/1] fix unexpected EOF for client when closing TLS session
Date: Wed, 05 Mar 2025 21:45:01 +0000 [thread overview]
Message-ID: <mailman.798.1741211145.293.pve-devel@lists.proxmox.com> (raw)
In-Reply-To: <20250305214447.128975-1-admin@truthsolo.net>
[-- Attachment #1: Type: message/rfc822, Size: 5965 bytes --]
From: Rob Rozestraten <admin@truthsolo.net>
To: pve-devel@lists.proxmox.com
Subject: [PATCH pve-http-server v2 1/1] fix unexpected EOF for client when closing TLS session
Date: Wed, 05 Mar 2025 21:45:01 +0000
Message-ID: <20250305214447.128975-2-admin@truthsolo.net>
When pve-http-server initiates the closure of a TLS session, it does not
send a TLS close notify, resulting in an unexpected EOF error on systems
with recent crypto policies. This can break functionality with other
applications, such as Foreman[0].
This behavior can be observed in the following cases:
* client uses HTTP/1.0 (no keepalive; server closes connection)
* client sends no data for 5 sec (timeout; server closes connection)
* server responds with 400 (no keepalive; server closes connection)
This patch sends the TLS close notify prior to socket teardown,
resulting in clean closure of TLS connections and no client error.
It also moves shutdown() to after the clearing of handlers. The reason
for this is stoptls() must come before shutdown(), but it also triggers
on_drain(), which calls client_do_disconnect() again. The extra call to
client_do_disconnect() is avoided inside accept_connections() by commit
f737984, but perhaps clearing the handlers prior to shutdown() will
avoid it in all cases.
[0]: https://github.com/theforeman/foreman_fog_proxmox/issues/325
Signed-off-by: Rob Rozestraten <admin@truthsolo.net>
---
changes since v1:
* move stoptls() after clearing of handlers
* move shutdown() after clearing of handlers
src/PVE/APIServer/AnyEvent.pm | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/PVE/APIServer/AnyEvent.pm b/src/PVE/APIServer/AnyEvent.pm
index 8a52836..e6d1028 100644
--- a/src/PVE/APIServer/AnyEvent.pm
+++ b/src/PVE/APIServer/AnyEvent.pm
@@ -141,11 +141,13 @@ sub client_do_disconnect {
my $shutdown_hdl = sub {
my $hdl = shift;
- shutdown($hdl->{fh}, 1);
# clear all handlers
$hdl->on_drain(undef);
$hdl->on_read(undef);
$hdl->on_eof(undef);
+
+ $hdl->stoptls();
+ shutdown($hdl->{fh}, 1);
};
if (my $proxyhdl = delete $reqstate->{proxyhdl}) {
--
2.48.1
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
parent reply other threads:[~2025-03-05 21:45 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20250305214447.128975-1-admin@truthsolo.net>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=mailman.798.1741211145.293.pve-devel@lists.proxmox.com \
--to=pve-devel@lists.proxmox.com \
--cc=admin@truthsolo.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal