security/acme-client: needsRenewal() ignores a renewed certificate that was never imported into the trust store
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Start in LeCertificate.php: read issue() (around the 'renewal not required' log and the import() call after validation->run()), needsRenewal(), and import(). Reproducing needs a certificate whose on-disk cert.pem is newer than the trust store copy, so the work involves the trust store and certRefId lookup, not just the renewal check. Done means a cron run imports the newer disk certificate in place, keeps the refid, sets status 200 and runs automations, and leaves a newer-or-equal trust store entry untouched. The maintainer has not yet agreed to the proposed approach, so confirm the design in the issue before writing code.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Important notices
Before you add a new report, we ask you kindly to acknowledge the following:
- I have read the contributing guide lines at https://github.com/opnsense/plugins/blob/master/CONTRIBUTING.md
- I have searched the existing issues, open and closed, and I'm convinced that mine is new.
- The title contains the plugin to which this issue belongs
Describe the bug
LeCertificate::needsRenewal() decides only from the certificate file that acme.sh wrote to certs/<id>/cert.pem (validFrom_time_t + renewInterval). It never checks whether that certificate was imported into the OPNsense trust store (LeCertificate.php#L400-L442).
If acme.sh has written a new cert.pem but import() and the automations did not run, issue() logs issue/renewal not required for certificate: ...
(#L328-L332) on every following cron run.
The trust store and all services keep serving the old certificate until it expires, the status stays at the failure status (e.g. 'validation failed').
issue() only calls import() after a successful validation->run()
(#L372-L381), so any failure between acme.sh writing cert.pem and the import leaves this state permanently. One concrete trigger is a failing stale deploy hook (see #5851, where acme.sh exits non-zero after issuing); a failed import, a killed process or a crash have the same effect. Same symptom as #5746.
Plugin version where the bug appeared: not determined. The code path is the same in 4.17 and current master.
Last known working version: unknown.
To Reproduce
Any way to get a newer cert.pem without a completed import will do. One that is easy to set up (see #5851):
- Issue an acme.sh based certificate and import it normally (Services > ACME Client > Certificates).
- Make the renewal fail after issuance, e.g. a recorded
Le_DeployHook=in/var/etc/acme-client/cert-home/<id>/*/*.confthat fails (acme.sh then exits non-zero after writingcert.pem; the plugin skips the import). - Wait until the certificate is due and run
configctl acmeclient cron-auto-renew. openssl x509 -in /var/etc/acme-client/certs/<id>/cert.pem -noout -serialshows a new serial, the trust store certificate (System > Trust > Certificates) still has the old one.- Run
configctl acmeclient cron-auto-renewagain:issue/renewal not required for certificate: ..., no import, no automations.
Expected behavior
Before logging "not required", the plugin should compare the on-disk certificate with the certificate in the trust store referenced by the ACME certificate's certRefId (SHA-256 fingerprint, or serial).
- If the disk certificate is newer, import it in place (this keeps the refid and thus the WebGUI binding), set status 200 and run the automations. This needs no ACME request, so it does not consume rate limit.
- If the import fails, log it and set an error status, so the next cron run retries.
- Only reconcile when the disk certificate is newer than the trust store copy, so a manually updated trust store certificate is not overwritten with an older file.
import()should also verify that the certificate and private key match (openssl_x509_check_private_key()) before overwriting the trust store entry. It currently does not.
Screenshots
N/A
Relevant log files
Plugin log, cron run (domain anonymized):
2026-10-31T00:00:xx AcmeClient: issue/renewal not required for certificate: *.sense.example.com
There were no other log entries for this certificate. The log of the original failing run was no longer available (only one day of /var/log/acmeclient was retained).
State on the box (read-only checks):
# acme certificate entry vs. WebGUI certificate: same refid
certRefId=644c12fbbec25 webgui ssl-certref=644c12fbbec25
status=400 lastUpdate=2026-08-24T09:16:51+02:00 statusLastUpdate=2026-10-24T00:20:45+02:00
# certs/<id>/cert.pem (acme.sh output)
serial=<REDACTED>7A0B
notBefore=Oct 23 21:22:09 2026 GMT notAfter=Jan 21 21:22:08 2027 GMT
# trust store / WebGUI certificate
serial <REDACTED>:3B:6D
notBefore Aug 24 06:18:12 2026 GMT notAfter Nov 22 06:18:11 2026 GMT
# acme.sh domain conf
Le_CertCreateTimeStr='2026-10-23T22:20:42Z'
Le_DeployHook='unifi,'
The Unifi automation was still attached at the time of the failure; the service had moved to another host, so the hook failed.
lastUpdate is still the August import time, i.e. import() never ran for the October certificate.
statusLastUpdate is 3 seconds after Le_CertCreateTimeStr.
Additional context
- Related: #5746 (same symptom, flagged as lacking the template), #5851 (stale deploy hook, a concrete trigger), #5719 / #4908 (non-zero acme.sh exit always reported as "validation failed").
- The WebGUI certificate was fixed by "(Re-) Import certificate" followed by "Run automations".
- Proposed fix: add a small
trustStoreOutdated()check inLeCertificateand call it inissue()before theneedsRenewal()gate. It looks up the trust cert bycertRefId(never by CN, duplicate common names are possible), compares fingerprints, applies the "newer only" guard, and then runsimport(true),setStatus(200)andrunAutomations(). It should honour the global and per-certificate auto-renewal settings when called from cron. I can prepare a PR if this approach is acceptable.
Environment
OPNsense 26.7.7
os-acme-client 4.17
acme.sh v3.1.6
DNS-01 validation, ECC (EC) key
- Ngôn ngữ chính
- PHP
- Star
- 1.2k
- Fork
- 932
- Merge trung bình
- 1 ngày 11 giờ
- Pull request đã merge (30 ngày)
- 22
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của opnsense/plugins
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
www/squid: configctl proxy stop returns before Squid exits, so stop+start (e.g. Monit restart) failsĐang mởsupport
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
opnsense/plugins#5983 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Maintainer thường phản hồi trong vòng 1 ngày
-
net/haproxy: IPv6 literal in real server "Source address" generates an invalid `source` directiveCó thể đã có người làm @fraenki đã nhận 6 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
opnsense/plugins#5973 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[dns/ddclient] Support hiding unused standard fields per service (optional_hiding)Có thể đã có người làm @bringha1 đã nhận 9 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của opnsense/plugins
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Automattic/blocks-engine#7881 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100
iruzen-dono/workless#117 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
magicsunday/webtrees-docker#285 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Flaky browser test: AreaHeadersTest 'shows Counting on the way while deferred tab counts load'Đang mởarea/tests type/bug when/soon
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
WP-CLI 3.0 fixes the cron lock and core download bugs described in the handbookCó thể đã có người làm @mayankmajeji đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
WordPress/hosting-handbook#521 ·