fix(tls): o painel de seguranca estava vazio em qualquer modo menos um

/admin/security mostrava "Nao foi possivel carregar os dados" porque
/api/v1/admin/tls respondia 503. A rota so era ligada quando o certificado
vinha do watcher do acme.json do Traefik, o unico provider que tinha metodos
de estado proprios.

Nesta instalacao o TRAEFIK_ACME_DIR nao esta definido e o STATIC_CERT_PATH
tambem nao, portanto o servidor cai no certificado autoassinado efemero -- ou
seja, o painel calava-se exactamente no estado em que o operador mais precisa
de ser avisado.

- ProviderStatus deriva o estado de qualquer port.CertProvider, lendo a folha
  do certificado que ele realmente serve
- o painel passa a ser ligado sempre que ha JWT_SECRET
- passa a dizer quem emitiu e se e autoassinado, com um aviso proprio: nas
  portas de correio um autoassinado e recusado por qualquer cliente que
  verifique, o que pesa mais do que uma validade ainda longe

CheckSignatureFrom nao serve para detectar isto: tambem exige que o emissor
seja uma CA, coisa que uma folha descartavel nunca declara, e por isso dava a
fallback degradada como correctamente emitida.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Lucas RayanandClaude Opus 5 committed 2026-08-24 09:11:49 -03:00
1 parent 9689f26dda
commit 136f9f339a
9 files changed
+194 -7

No files matched your search

@@ -238,9 +238,15 @@ func run(cfg config) {
// The TLS panel reads the live watcher instead of the constants the admin
// service used to return, which reported a healthy certificate whatever
// the process actually held.
if source, ok := certProvider.(httppresentation.TlsStatusSource); ok {
router.SetAdminTlsAPI(source, cfg.PrimaryMailHost, cfg.TLSMode, cfg.JwtSecret, cfg.CertPollInterval)
// Wired for every certificate source, not just the Traefik watcher. Only
// the watcher carried status methods, so with TRAEFIK_ACME_DIR unset the
// panel answered 503 and showed "could not load the data" - in exactly the
// state an operator most needs to see, the degraded self-signed fallback.
tlsStatus, ok := certProvider.(httppresentation.TlsStatusSource)
if !ok {
tlsStatus = tlsprovider.NewProviderStatus(certProvider)
}
router.SetAdminTlsAPI(tlsStatus, cfg.PrimaryMailHost, cfg.TLSMode, cfg.JwtSecret, cfg.CertPollInterval)
// Real-time updates: the outbox relay reads the events delivery wrote in
// its own transaction and hands them to the hub, which pushes them to the