Issue real certificates via ACME DNS-01

Tunnels now get a per-tunnel certificate from the configured ACME CA
(Let's Encrypt by default) with DNS-01 through Porkbun, keeping the
client's CSR and key. Issuance is asynchronous (issuing/ready/failed);
the account persists in the store, renewals run in a 30-day window with
retries, and a failed renewal keeps the old certificate serving.
Switching from the local CA reissues existing tunnels automatically,
and the admin dashboard shows the issuer and certificate state.

Verified against Pebble and Let's Encrypt staging.
This commit is contained in:
2026-10-25 23:33:52 +08:00
parent 05d326f47f
commit 437a2e447e
25 changed files with 1491 additions and 79 deletions
+8
View File
@@ -18,6 +18,7 @@ type adminServer struct {
Domain string `json:"domain"`
Version string `json:"version"`
Go string `json:"go"`
Issuer string `json:"issuer"`
UptimeSeconds int64 `json:"uptime_seconds"`
}
@@ -39,6 +40,9 @@ type adminTunnel struct {
Routes []string `json:"routes"`
Visitors int `json:"visitors"`
CertificateExpiry string `json:"certificate_expiry,omitempty"`
CertificateState string `json:"certificate_state,omitempty"`
CertificateIssuer string `json:"certificate_issuer,omitempty"`
CertificateError string `json:"certificate_error,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
}
@@ -98,6 +102,7 @@ func (a *API) adminOverviewHandler(w http.ResponseWriter, r *http.Request) {
Domain: a.Domain,
Version: a.Version,
Go: runtime.Version(),
Issuer: a.issuerName(),
UptimeSeconds: int64(time.Since(a.StartedAt).Seconds()),
},
CA: adminCA{Expires: a.caExpiry()},
@@ -137,6 +142,9 @@ func (a *API) adminOverviewHandler(w http.ResponseWriter, r *http.Request) {
}
if t.Certificate != nil {
entry.CertificateExpiry = t.Certificate.Expiry
entry.CertificateState = certState(t.Certificate).Type
entry.CertificateIssuer = t.Certificate.Issuer
entry.CertificateError = t.Certificate.Reason
}
overview.Tunnels = append(overview.Tunnels, entry)
}