public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com, pbs-devel@lists.proxmox.com
Subject: [PATCH proxmox-backup v4 7/8] pbs-client: honor already verified fingerprint
Date: Wed,  1 Jul 2026 12:30:51 +0200	[thread overview]
Message-ID: <20260701103120.1593265-8-d.csapak@proxmox.com> (raw)
In-Reply-To: <20260701103120.1593265-1-d.csapak@proxmox.com>

When there is an invalid fingerprint or a mismatch and the client is
executed in an interactive way, the user is asked if he wants to trust
the fingerprint.

OpenSSL might evaluate the verify callback multiple times per
certificate (for different errors for example), so we have to check
if the fingerprint matches the one we already verified.

Otherwise the user gets multiple prompts directly after another.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 pbs-client/src/http_client.rs | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/pbs-client/src/http_client.rs b/pbs-client/src/http_client.rs
index 27f5a1782..f953a1e58 100644
--- a/pbs-client/src/http_client.rs
+++ b/pbs-client/src/http_client.rs
@@ -431,6 +431,18 @@ impl HttpClient {
             let interactive = options.interactive;
             let fingerprint_cache = options.fingerprint_cache;
             let prefix = options.prefix.clone();
+            let check_fp_verified = |verified_fingerprint: &Arc<Mutex<Option<String>>>,
+                                     fingerprint: &Fingerprint|
+             -> bool {
+                let verified = verified_fingerprint.lock().unwrap();
+                if let Some(verified) = &*verified {
+                    if *verified == fingerprint.to_string() {
+                        // already verified
+                        return true;
+                    }
+                }
+                false
+            };
             ssl_connector_builder.set_verify_callback(
                 openssl::ssl::SslVerifyMode::PEER,
                 move |valid, ctx| match openssl_verify_callback(
@@ -453,6 +465,9 @@ impl HttpClient {
                                 error!("certificate validation failed - failed to calculate FP - {error_stack}")
                             },
                             SslVerifyError::UntrustedCertificate { fingerprint } => {
+                                if check_fp_verified(&verified_fingerprint, &fingerprint) {
+                                    return true;
+                                }
                                 if interactive && std::io::stdin().is_terminal() {
                                     match Self::interactive_fp_check(prefix.as_deref(), &server, verified_fingerprint.clone(), fingerprint_cache, fingerprint) {
                                         Ok(()) => return true,
@@ -461,6 +476,9 @@ impl HttpClient {
                                 }
                             }
                             SslVerifyError::FingerprintMismatch { fingerprint, expected } => {
+                                if check_fp_verified(&verified_fingerprint, &fingerprint) {
+                                    return true;
+                                }
                                 warn!("WARNING: certificate fingerprint does not match expected fingerprint!");
                                 warn!("expected:    {expected}");
 
-- 
2.47.3





  parent reply	other threads:[~2026-07-01 10:32 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-01 10:30 [PATCH proxmox{,-backup,-websocket-tunnel} v4 0/8] unify openssl callback logic Dominik Csapak
2026-07-01 10:30 ` [PATCH proxmox v4 1/8] http: factor out openssl verification callback Dominik Csapak
2026-07-01 10:30 ` [PATCH proxmox v4 2/8] http: tls: use legacy behavior when PROXMOX_OLD_TLS_CHECK is set to "1" Dominik Csapak
2026-07-01 13:36   ` Shannon Sterz
2026-07-01 10:30 ` [PATCH proxmox v4 3/8] http: tls: add warning if old check behavior is enabled and triggered Dominik Csapak
2026-07-01 10:30 ` [PATCH proxmox v4 4/8] http: tls: add integration tests for openssl verify callbacks Dominik Csapak
2026-07-01 10:30 ` [PATCH proxmox v4 5/8] client: use proxmox-http's openssl verification callback Dominik Csapak
2026-07-01 10:30 ` [PATCH proxmox-backup v4 6/8] pbs-client: use proxmox-https openssl callback Dominik Csapak
2026-07-01 13:36   ` Shannon Sterz
2026-07-01 10:30 ` Dominik Csapak [this message]
2026-07-01 10:30 ` [PATCH proxmox-websocket-tunnel v4 8/8] use proxmox-http's " Dominik Csapak
2026-07-01 13:35   ` Shannon Sterz
2026-07-01 13:35 ` [PATCH proxmox{,-backup,-websocket-tunnel} v4 0/8] unify openssl callback logic Shannon Sterz

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=20260701103120.1593265-8-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /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