From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id BE9511FF09B for ; Mon, 14 Sep 2026 18:19:50 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 9E05C215FE; Mon, 14 Sep 2026 18:19:48 +0200 (CEST) From: Samuel Rufinatscha To: pdm-devel@lists.proxmox.com Subject: [PATCH proxmox 1/3] acme-api: extract certificate order finalization helper Date: Mon, 14 Sep 2026 18:19:29 +0200 Message-ID: <20260914161931.380138-2-s.rufinatscha@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260914161931.380138-1-s.rufinatscha@proxmox.com> References: <20260914161931.380138-1-s.rufinatscha@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1789402768986 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.364 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: 3FYM24G3H3J3LR52OPVCMIEDBJHKGYOA X-Message-ID-Hash: 3FYM24G3H3J3LR52OPVCMIEDBJHKGYOA X-MailFrom: s.rufinatscha@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 Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Move order finalization and certificate download into a private helper. Signed-off-by: Samuel Rufinatscha --- proxmox-acme-api/src/certificate_helpers.rs | 23 ++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/proxmox-acme-api/src/certificate_helpers.rs b/proxmox-acme-api/src/certificate_helpers.rs index 3921b18e..1db41564 100644 --- a/proxmox-acme-api/src/certificate_helpers.rs +++ b/proxmox-acme-api/src/certificate_helpers.rs @@ -119,8 +119,20 @@ pub async fn order_certificate( info!("Creating CSR"); let csr = proxmox_acme::util::Csr::generate(&identifiers, &Default::default())?; + let certificate = finalize_order(&mut acme, &order.location, &csr.data).await?; + + Ok(Some(OrderedCertificate { + certificate, + private_key_pem: csr.private_key_pem, + })) +} + +async fn finalize_order( + acme: &mut AcmeClient, + order_url: &str, + csr: &[u8], +) -> Result, Error> { let mut finalize_error_cnt = 0u8; - let order_url = &order.location; let mut order; loop { use proxmox_acme::order::Status; @@ -134,7 +146,7 @@ pub async fn order_certificate( .finalize .as_deref() .ok_or_else(|| format_err!("missing 'finalize' URL in order"))?; - if let Err(err) = acme.finalize(finalize, &csr.data).await { + if let Err(err) = acme.finalize(finalize, csr).await { if finalize_error_cnt >= 5 { return Err(err); } @@ -149,7 +161,7 @@ pub async fn order_certificate( .finalize .as_deref() .ok_or_else(|| format_err!("missing 'finalize' URL in order"))?; - acme.finalize(finalize, &csr.data).await?; + acme.finalize(finalize, csr).await?; tokio::time::sleep(Duration::from_secs(5)).await; } Status::Processing => { @@ -174,10 +186,7 @@ pub async fn order_certificate( ) .await?; - Ok(Some(OrderedCertificate { - certificate: certificate.to_vec(), - private_key_pem: csr.private_key_pem, - })) + Ok(certificate.to_vec()) } async fn request_validation( -- 2.47.3