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 v3 5/6] pbs-client: honor already verified fingerprint
Date: Wed, 17 Jun 2026 10:59:17 +0200	[thread overview]
Message-ID: <20260617085949.1528300-6-d.csapak@proxmox.com> (raw)
In-Reply-To: <20260617085949.1528300-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 | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/pbs-client/src/http_client.rs b/pbs-client/src/http_client.rs
index ea6e5d7fa..14aa4d317 100644
--- a/pbs-client/src/http_client.rs
+++ b/pbs-client/src/http_client.rs
@@ -422,6 +422,17 @@ 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: &str| -> bool {
+                    let verified = verified_fingerprint.lock().unwrap();
+                    if let Some(verified) = &*verified {
+                        if verified == fingerprint {
+                            // already verified
+                            return true;
+                        }
+                    }
+                    false
+                };
             ssl_connector_builder.set_verify_callback(
                 openssl::ssl::SslVerifyMode::PEER,
                 move |valid, ctx| match openssl_verify_callback(
@@ -439,6 +450,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,
@@ -447,6 +461,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-06-17  9:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-17  8:59 [PATCH proxmox{,-backup,-websocket-tunnel} v3 0/6] unify openssl callback logic Dominik Csapak
2026-06-17  8:59 ` [PATCH proxmox v3 1/6] http: factor out openssl verification callback Dominik Csapak
2026-06-17  8:59 ` [PATCH proxmox v3 2/6] http: tls: use legacy behavior when PROXMOX_NEW_TLS_CHECK is not set Dominik Csapak
2026-06-17  8:59 ` [PATCH proxmox v3 3/6] client: use proxmox-http's openssl verification callback Dominik Csapak
2026-06-17  8:59 ` [PATCH proxmox-backup v3 4/6] pbs-client: use proxmox-https openssl callback Dominik Csapak
2026-06-17  8:59 ` Dominik Csapak [this message]
2026-06-17  8:59 ` [PATCH proxmox-websocket-tunnel v3 6/6] use proxmox-http's " Dominik Csapak

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=20260617085949.1528300-6-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