From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id E850AB943 for ; Mon, 3 Jul 2023 09:19:33 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id C18F518C5F for ; Mon, 3 Jul 2023 09:19:03 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Mon, 3 Jul 2023 09:19:02 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 7CA1C43689; Mon, 3 Jul 2023 09:19:02 +0200 (CEST) From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= To: pve-devel@lists.proxmox.com Cc: Roland Kletzing Date: Mon, 3 Jul 2023 09:18:51 +0200 Message-Id: <20230703071851.162066-1-f.gruenbichler@proxmox.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.071 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH http-server] fix #4802: reduce CA lookups while proxying X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jul 2023 07:19:34 -0000 openssl as packaged in Debian bookworm now ships a compat symlink for the "combined" CA certificates file (CAfile) as managed by update-ca-certificates. this symlink is in addition to the CApath one that has been around for a file. the new symlink in turn gets picked up by openssl-using code that uses the default values for the trust store. every TLS context initialization now reads the full combined file, even if no TLS is actually employed on a connection. we do such an initialization for every proxied connection (where our HTTP server is the client). by specifying an explicit CA path (that is identical to the default one), the old behaviour of looking up each CA certificate individually iff needed is enabled again. for an API endpoint where HTTP request handling is the bottle neck (as opposed to the actual API handler), this improves performance of proxied requests to be back in line with unproxied ones handled directly by the unprivileged daemon. for all proxied requests, CPU usage is decreased as well. the default CAfile and CApath contain the same certificates, so there should be no change in trusted certificates. additionally, certificate fingerprints are pinned in this context and verified against the cache of pinned fingerprints. Reported-by: Roland Kletzing Signed-off-by: Fabian Grünbichler --- Notes: CA cert access was verified using strace src/PVE/APIServer/AnyEvent.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PVE/APIServer/AnyEvent.pm b/src/PVE/APIServer/AnyEvent.pm index 1fd7a74..07d8f20 100644 --- a/src/PVE/APIServer/AnyEvent.pm +++ b/src/PVE/APIServer/AnyEvent.pm @@ -767,6 +767,7 @@ sub proxy_request { sslv2 => 0, sslv3 => 0, verify => 1, + ca_path => '/usr/lib/ssl/certs', # to avoid loading the combined CA cert file verify_cb => sub { my (undef, undef, undef, $depth, undef, undef, $cert) = @_; # we don't care about intermediate or root certificates -- 2.39.2