feat(statuspage): obtain tls certificates on demand for custom domains

With UPTIME_STATUSPAGE_TLS the server serves HTTPS with ACME
certificates for its hosts and for verified custom domains of pages it
may serve, shared by all instances through the API. Plain HTTP answers
ACME challenges and health checks and redirects everything else.

Closes #22

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-22 08:54:08 +01:00
1 parent 46f1f82481
commit 4d1db0943e
8 files changed
+255 -17

No files matched your search

+16 -10
View File
@@ -143,16 +143,7 @@ func TestStatusPages(t *testing.T) {
if _, err := platform.Page(context.Background(), domain, ""); !errors.Is(err, agentapi.ErrNotFound) {
t.Errorf("Page(unverified domain) error = %v, want not found", err)
}
saved := *api.LookupTXT
t.Cleanup(func() { *api.LookupTXT = saved })
*api.LookupTXT = func(_ context.Context, name string) ([]string, error) {
if name == record["name"] {
return []string{"something else", record["value"].(string)}, nil
}
return nil, errors.New("no such record")
}
st, body = owner.do("POST", "/api/v1/org/statuspages/"+pageID+"/domain/verify", nil)
expect(t, "verify domain", st, body, http.StatusNoContent, "")
verifyDomain(t, owner, pageID, record)
if snap, err := platform.Page(context.Background(), domain, ""); err != nil || snap.Title != "Acme Status" {
t.Errorf("Page(verified domain) = %v, %v", snap.Title, err)
}
@@ -203,3 +194,18 @@ func editorEmail(b *browser) string {
_, me := b.do("GET", "/api/v1/me", nil)
return me["email"].(string)
}
// verifyDomain answers the TXT lookup with record and verifies the domain.
func verifyDomain(t *testing.T, owner *browser, pageID string, record map[string]any) {
t.Helper()
saved := *api.LookupTXT
t.Cleanup(func() { *api.LookupTXT = saved })
*api.LookupTXT = func(_ context.Context, name string) ([]string, error) {
if name == record["name"] {
return []string{"something else", record["value"].(string)}, nil
}
return nil, errors.New("no such record")
}
st, body := owner.do("POST", "/api/v1/org/statuspages/"+pageID+"/domain/verify", nil)
expect(t, "verify domain", st, body, http.StatusNoContent, "")
}