fix(tls): sem watcher nao ha veredito, e o README passa a explicar os modos
Com TLS_MODE=acme o certificado e emitido por este servico, nao vigiado em disco, portanto nao ha watcher para estar saudavel. O painel reportava false e mostrava "indisponivel" em permanencia, ao lado de um certificado perfeitamente valido. Passa a ser null, e a pagina nao mostra veredito nenhum. O README ganha uma seccao sobre os dois modos de certificado. O modo traefik falha de duas maneiras silenciosas -- sem router para o PRIMARY_MAIL_HOST o nome nunca chega ao acme.json, e o acme.json fica em 600 do root, ilegivel para o utilizador nao-root do contentor. Nos dois casos o HTTPS continua a funcionar porque quem o serve e o proxy, enquanto as portas de correio caem no autoassinado e sao recusadas por qualquer cliente que verifique. Foi exactamente o que aconteceu nesta instalacao. Actualizado tambem o que ja nao esta por acabar: a resposta de ausencia, a assinatura e as regras Sieve sao consumidas, e a reconciliacao de DNS conduz o estado em vez de o relatar. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1e7c6a118c
commit
7f8d9b7ff1
7 files changed
+119
-29
No files matched your search
@@ -43,13 +43,16 @@ func (a *adminTlsAPI) handleStatus(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
status := map[string]any{
|
||||
"tls_mode": a.tlsMode,
|
||||
"mail_host": a.mailHost,
|
||||
"has_certificate": a.source.HasCertificateFor(a.mailHost),
|
||||
"unknown_sni_total": a.source.UnknownSNICount(),
|
||||
"last_reload": nil,
|
||||
"last_change": nil,
|
||||
"watcher_healthy": false,
|
||||
"tls_mode": a.tlsMode,
|
||||
"mail_host": a.mailHost,
|
||||
"has_certificate": a.source.HasCertificateFor(a.mailHost),
|
||||
"unknown_sni_total": a.source.UnknownSNICount(),
|
||||
"last_reload": nil,
|
||||
"last_change": nil,
|
||||
// Null, not false. A source that reloads from disk reports a time and
|
||||
// gets a verdict; one that issues its own certificate has no watcher to
|
||||
// be unhealthy, and saying "unavailable" there is a false alarm.
|
||||
"watcher_healthy": nil,
|
||||
"certificate_expires": nil,
|
||||
"expires_in_days": nil,
|
||||
"state": "UNKNOWN",
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package httppresentation
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Under TLS_MODE=acme the certificate is issued by this service, not watched
|
||||
// on disk, so there is no watcher to be healthy or unhealthy. Reporting false
|
||||
// there put a standing "unavailable" warning on a panel whose certificate was
|
||||
// perfectly fine.
|
||||
func TestTlsStatus_NoWatcherVerdictWithoutAReloadTime(t *testing.T) {
|
||||
api := &adminTlsAPI{
|
||||
source: stillSource{},
|
||||
mailHost: "mail.example.test",
|
||||
tlsMode: "acme",
|
||||
sessions: testVerifier(interopSecret),
|
||||
pollPeriod: time.Minute,
|
||||
}
|
||||
|
||||
rec := httptest.NewRecorder()
|
||||
req := httptest.NewRequest(http.MethodGet, "/api/v1/admin/tls", nil)
|
||||
req.Header.Set("Authorization", "Bearer "+adminSurfaceToken2())
|
||||
api.sessions.now = func() time.Time { return time.Unix(interopIssuedAt+60, 0) }
|
||||
api.handleStatus(rec, req)
|
||||
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("answered %d: %s", rec.Code, rec.Body)
|
||||
}
|
||||
|
||||
var body map[string]any
|
||||
if err := json.NewDecoder(rec.Body).Decode(&body); err != nil {
|
||||
t.Fatalf("decode: %v", err)
|
||||
}
|
||||
if v, present := body["watcher_healthy"]; !present || v != nil {
|
||||
t.Errorf("watcher_healthy = %v, want null: there is no watcher to judge", v)
|
||||
}
|
||||
}
|
||||
|
||||
// stillSource holds a certificate but never reloads: exactly what a
|
||||
// self-issuing provider looks like.
|
||||
type stillSource struct{}
|
||||
|
||||
func (stillSource) EarliestExpiry() (string, time.Time, bool) {
|
||||
return "mail.example.test", time.Now().Add(60 * 24 * time.Hour), true
|
||||
}
|
||||
func (stillSource) LastReload() time.Time { return time.Time{} }
|
||||
func (stillSource) LastChange() time.Time { return time.Time{} }
|
||||
func (stillSource) UnknownSNICount() int64 { return 0 }
|
||||
func (stillSource) HasCertificateFor(string) bool { return true }
|
||||
@@ -161,7 +161,8 @@
|
||||
"search": "Search",
|
||||
"status": "Status",
|
||||
"unavailable": "Unavailable",
|
||||
"userPortal": "Webmail"
|
||||
"userPortal": "Webmail",
|
||||
"notApplicable": "Not applicable"
|
||||
},
|
||||
"errors": {
|
||||
"forbidden": "You do not have access to this",
|
||||
|
||||
@@ -161,7 +161,8 @@
|
||||
"search": "Buscar",
|
||||
"status": "Estado",
|
||||
"unavailable": "No disponible",
|
||||
"userPortal": "Webmail"
|
||||
"userPortal": "Webmail",
|
||||
"notApplicable": "No aplicable"
|
||||
},
|
||||
"errors": {
|
||||
"forbidden": "No tiene acceso a esto",
|
||||
|
||||
@@ -161,7 +161,8 @@
|
||||
"search": "Buscar",
|
||||
"status": "Status",
|
||||
"unavailable": "Indisponível",
|
||||
"userPortal": "Webmail"
|
||||
"userPortal": "Webmail",
|
||||
"notApplicable": "Nao aplicavel"
|
||||
},
|
||||
"errors": {
|
||||
"forbidden": "Você não tem acesso a isto",
|
||||
|
||||
@@ -318,12 +318,23 @@ export default function AdminSecurityPage() {
|
||||
|
||||
<div className="flex flex-col gap-1 rounded-xl bg-dark-card p-3.5 shadow-edge">
|
||||
<div className="text-xs text-slate-400">{t("admin.watcherHealthy")}</div>
|
||||
{/* Null means there is no watcher to judge - the certificate
|
||||
is issued by this server rather than read from disk - so no
|
||||
verdict is shown instead of a standing false alarm. */}
|
||||
<div
|
||||
className={`text-[15px] font-medium ${
|
||||
tlsStatus.watcher_healthy ? "text-indigo-400" : "text-amber-400"
|
||||
tlsStatus.watcher_healthy === null || tlsStatus.watcher_healthy === undefined
|
||||
? "text-slate-400"
|
||||
: tlsStatus.watcher_healthy
|
||||
? "text-indigo-400"
|
||||
: "text-amber-400"
|
||||
}`}
|
||||
>
|
||||
{tlsStatus.watcher_healthy ? t("ui.healthy") : t("common.unavailable")}
|
||||
{tlsStatus.watcher_healthy === null || tlsStatus.watcher_healthy === undefined
|
||||
? t("common.notApplicable")
|
||||
: tlsStatus.watcher_healthy
|
||||
? t("ui.healthy")
|
||||
: t("common.unavailable")}
|
||||
</div>
|
||||
<div className="text-[11.5px] text-slate-500">
|
||||
{t("admin.lastReload")}:{" "}
|
||||
|
||||
Reference in new issue
Block a user