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 EC7731FF0AA for ; Tue, 06 Oct 2026 14:31:51 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 2244F214CD; Tue, 06 Oct 2026 14:31:42 +0200 (CEST) From: David Riley To: pve-devel@lists.proxmox.com Subject: [PATCH pve-manager 2/2] fix #8006: api: acme: lifetime-based certificate renewal threshold Date: Tue, 6 Oct 2026 14:31:20 +0200 Message-ID: <20261006123120.68750-3-d.riley@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261006123120.68750-1-d.riley@proxmox.com> References: <20261006123120.68750-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: 1791289896034 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.786 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: 5EYXQZTM5UCF6ZT3QAQNIOIEFE2SQDIJ X-Message-ID-Hash: 5EYXQZTM5UCF6ZT3QAQNIOIEFE2SQDIJ 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 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 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/PVE/API2/ACME.pm b/PVE/API2/ACME.pm index a948a72a..4f2590f0 100644 --- a/PVE/API2/ACME.pm +++ b/PVE/API2/ACME.pm @@ -261,12 +261,15 @@ __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 $lead_days = int($lead_time / (24 * 60 * 60)); + 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.", + "Certificate does not expire within the next $lead_days days, and 'force' is not set.", }, ) if !$expires_soon && !$param->{force}; -- 2.47.3