security/acme-client: needsRenewal() ignores a renewed certificate that was never imported into the trust store
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- PHP
- Estrellas
- 1.2k
- Forks
- 932
- Merge medio
- 1 d 11 h
- PR fusionados (30 d)
- 22
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de opnsense/plugins
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
www/squid: configctl proxy stop returns before Squid exits, so stop+start (e.g. Monit restart) failsAbiertosupport
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
opnsense/plugins#5983 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
Los mantenedores suelen responder en 1 día
-
net/haproxy: IPv6 literal in real server "Source address" generates an invalid `source` directivePosiblemente ocupada @fraenki la tomó hace 6 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
opnsense/plugins#5973 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
[dns/ddclient] Support hiding unused standard fields per service (optional_hiding)Posiblemente ocupada @bringha1 la tomó hace 9 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
Todos los issues de opnsense/plugins
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Automattic/blocks-engine#7881 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 86/100
iruzen-dono/workless#117 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
magicsunday/webtrees-docker#285 ·
Los mantenedores suelen responder en 1 día
-
Flaky browser test: AreaHeadersTest 'shows Counting on the way while deferred tab counts load'Abiertoarea/tests type/bug when/soon
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
WP-CLI 3.0 fixes the cron lock and core download bugs described in the handbookPosiblemente ocupada @mayankmajeji la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
WordPress/hosting-handbook#521 ·