security/acme-client: needsRenewal() ignores a renewed certificate that was never imported into the trust store
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- PHP
- Stelle
- 1.2k
- Fork
- 932
- Merge medio
- 1g 11h
- PR unite (30g)
- 22
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di opnsense/plugins
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
www/squid: configctl proxy stop returns before Squid exits, so stop+start (e.g. Monit restart) failsApertasupport
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
opnsense/plugins#5983 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
I maintainer di solito rispondono entro 1 giorno
-
net/haproxy: IPv6 literal in real server "Source address" generates an invalid `source` directiveForse già presa @fraenki l’ha presa 6 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
opnsense/plugins#5973 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
[dns/ddclient] Support hiding unused standard fields per service (optional_hiding)Forse già presa @bringha1 l’ha presa 9 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di opnsense/plugins
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
Automattic/blocks-engine#7881 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 86/100
iruzen-dono/workless#117 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
magicsunday/webtrees-docker#285 ·
I maintainer di solito rispondono entro 1 giorno
-
Flaky browser test: AreaHeadersTest 'shows Counting on the way while deferred tab counts load'Apertaarea/tests type/bug when/soon
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
WP-CLI 3.0 fixes the cron lock and core download bugs described in the handbookForse già presa @mayankmajeji l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
WordPress/hosting-handbook#521 ·