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 67E7A1FF0C0 for ; Wed, 21 Oct 2026 11:53:08 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id DA429216A8; Wed, 21 Oct 2026 11:52:54 +0200 (CEST) From: David Riley To: pve-devel@lists.proxmox.com Subject: [PATCH pve-manager v3 3/4] fix #8006: api: acme: use lifetime-based certificate renewal lead time Date: Wed, 21 Oct 2026 11:52:28 +0200 Message-ID: <20261021095229.50842-4-d.riley@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261021095229.50842-1-d.riley@proxmox.com> References: <20261021095229.50842-1-d.riley@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1792576369772 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.659 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: V6XK4P3YNHICZUXKO6CVP26WWH5C7JVZ X-Message-ID-Hash: V6XK4P3YNHICZUXKO6CVP26WWH5C7JVZ X-MailFrom: d.riley@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 CC: David Riley X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Replace the hardcoded 30-day renewal check with a dynamic threshold based on the certificate's actual lifetime. Signed-off-by: David Riley Reviewed-by: Michael Köppl Tested-by: Michael Köppl --- PVE/API2/ACME.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/PVE/API2/ACME.pm b/PVE/API2/ACME.pm index a948a72a..21ed3878 100644 --- a/PVE/API2/ACME.pm +++ b/PVE/API2/ACME.pm @@ -243,7 +243,8 @@ __PACKAGE__->register_method({ node => get_standard_option('pve-node'), force => { type => 'boolean', - description => 'Force renewal even if expiry is more than 30 days away.', + description => + 'Force renewal even if the certificate is not yet due for renewal.', optional => 1, default => 0, }, @@ -261,12 +262,13 @@ __PACKAGE__->register_method({ raise("No current (custom) certificate found, please order a new certificate!\n") if !-e "${cert_prefix}.pem"; + my $lead_time = PVE::Certificate::get_cert_renew_lead_time("${cert_prefix}.pem"); + my $expires_soon = - PVE::Certificate::check_expiry("${cert_prefix}.pem", time() + 30 * 24 * 60 * 60); + PVE::Certificate::check_expiry("${cert_prefix}.pem", time() + $lead_time); raise_param_exc( { - 'force' => - "Certificate does not expire within the next 30 days, and 'force' is not set.", + 'force' => "Certificate is not yet due for renewal, and 'force' is not set.", }, ) if !$expires_soon && !$param->{force}; -- 2.47.3