From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 506AA1FF0B4 for ; Tue, 10 Nov 2026 12:07:40 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 05263214F4; Tue, 10 Nov 2026 12:07:40 +0100 (CET) From: "Max R. Carrara" To: pbs-devel@lists.proxmox.com Subject: [PATCH proxmox v3 3/5] rest-server: connection: log cause of TLS handshake check errors Date: Tue, 10 Nov 2026 12:07:25 +0100 Message-ID: <20261110110728.144880-4-m.carrara@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261110110728.144880-1-m.carrara@proxmox.com> References: <20261110110728.144880-1-m.carrara@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1794308854674 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.312 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: OM2K4NJNOGRJ6CQVB4JH5EXUB7SNHU2F X-Message-ID-Hash: OM2K4NJNOGRJ6CQVB4JH5EXUB7SNHU2F X-MailFrom: m.carrara@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Errors from checking for a TLS handshake were logged with only their outermost context, which hid the underlying OS error. For example, a failed peek was only reported as "couldn't peek into incoming TCP stream", without saying why it failed. Log the whole error chain on a single line instead, so that the actual reason shows up in the logs. Also, do not keep the error from `tokio::time::timeout` in the error context, because it doesn't tell us any additional information. Signed-off-by: Max R. Carrara --- proxmox-rest-server/src/connection.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/proxmox-rest-server/src/connection.rs b/proxmox-rest-server/src/connection.rs index 00ee771b..9b3c1371 100644 --- a/proxmox-rest-server/src/connection.rs +++ b/proxmox-rest-server/src/connection.rs @@ -489,11 +489,11 @@ impl AcceptBuilder { "[{peer}] failed to accept connection - connection channel closed: {send_err}" ); } } Err(err) => { - log::error!("[{peer}] failed to check for TLS handshake: {err}"); + log::error!("[{peer}] failed to check for TLS handshake: {err:#}"); } } } async fn wait_for_client_tls_handshake( @@ -550,13 +550,15 @@ impl AcceptBuilder { }) .await .context("couldn't peek into incoming TCP stream") }; - tokio::time::timeout(timeout, future) - .await - .context("timed out while waiting for client to initiate TLS handshake")? + // The elapsed error carries no information beyond the timeout itself, so do not keep it as + // the cause. + tokio::time::timeout(timeout, future).await.map_err(|_| { + format_err!("timed out while waiting for client to initiate TLS handshake") + })? } } /// Checks whether an [SSL 3.0 / TLS plaintext fragment][0] being part of a /// SSL / TLS handshake is contained in the given buffer. @@ -654,11 +656,11 @@ mod tests { fn assert_timeout_error(result: Result) { let err = result.expect_err("check must time out"); assert_eq!( format!("{err:#}"), - "timed out while waiting for client to initiate TLS handshake: deadline has elapsed", + "timed out while waiting for client to initiate TLS handshake", ); } #[tokio::test] async fn a_tls_client_is_detected() { -- 2.47.3