From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 892E11FF0AA for ; Tue, 20 Oct 2026 10:25:07 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 51AA42162D; Tue, 20 Oct 2026 10:25:02 +0200 (CEST) From: David Riley To: pve-devel@lists.proxmox.com Subject: [PATCH pve-manager v2 2/2] fix #8006: api: acme: lifetime-based certificate renewal threshold Date: Tue, 20 Oct 2026 10:24:15 +0200 Message-ID: <20261020082415.35215-3-d.riley@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261020082415.35215-1-d.riley@proxmox.com> References: <20261020082415.35215-1-d.riley@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1792484688609 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.699 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: SVC3X6VN4LLUTQOMZKOI2FFLN5OI4KBJ X-Message-ID-Hash: SVC3X6VN4LLUTQOMZKOI2FFLN5OI4KBJ 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 limit with a threshold based on the certificate's actual lifetime. The previous hardcoded limit caused excessive daily renewals for short-lived certificates (e.g., 31 days). This change ensures they renew at sensible intervals, avoiding upstream rate limits. Link: https://bugzilla.proxmox.com/show_bug.cgi?id=8006 Signed-off-by: David Riley --- PVE/API2/ACME.pm | 10 ++++++---- bin/pveupdate | 4 +++- 2 files changed, 9 insertions(+), 5 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}; diff --git a/bin/pveupdate b/bin/pveupdate index b1960c35..a014d1d3 100755 --- a/bin/pveupdate +++ b/bin/pveupdate @@ -83,7 +83,9 @@ eval { if ($acme_node_config && $acme_node_config->{domains}) { my $cert = PVE::CertHelpers::cert_path_prefix($nodename) . ".pem"; if (-e $cert) { - if (PVE::Certificate::check_expiry($cert, time() + 30 * 24 * 60 * 60)) { + my $lead_time = PVE::Certificate::get_cert_renew_lead_time($cert); + + if (PVE::Certificate::check_expiry($cert, time() + $lead_time)) { PVE::API2::ACME->renew_certificate({ node => $nodename }); } else { syslog( -- 2.47.3