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:
@@ -0,0 +1,33 @@
|
||||
package server
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestChallengeRecordName(t *testing.T) {
|
||||
if got := challengeRecordName("abc123.tunnel.tzgyn.dev"); got != "_acme-challenge.abc123.tunnel.tzgyn.dev" {
|
||||
t.Errorf("challengeRecordName = %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRelativeRecordName(t *testing.T) {
|
||||
got, err := relativeRecordName("_acme-challenge.abc123.tunnel.tzgyn.dev", "tzgyn.dev")
|
||||
if err != nil || got != "_acme-challenge.abc123.tunnel" {
|
||||
t.Errorf("relativeRecordName = %q, %v", got, err)
|
||||
}
|
||||
if _, err := relativeRecordName("_acme-challenge.other.example.com", "tzgyn.dev"); err == nil {
|
||||
t.Error("expected an error for a record outside the zone")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDNSZone(t *testing.T) {
|
||||
cases := map[string]string{
|
||||
"tunnel.tzgyn.dev": "tzgyn.dev",
|
||||
"tzgyn.dev": "tzgyn.dev",
|
||||
"a.b.example.co.uk": "b.example.co.uk",
|
||||
"localhost": "localhost",
|
||||
}
|
||||
for domain, want := range cases {
|
||||
if got := DNSZone(domain); got != want {
|
||||
t.Errorf("DNSZone(%q) = %q, want %q", domain, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user