Internal Nebula services previously used a step-ca ACME server for TLS certificates. This required running a CA service and distributing root certificates to all clients. Implemented a custom ACME DNS-01 challenge system that allows Nebula services to obtain Let's Encrypt certificates. The system consists of: a Perl API service (acme-dns-api) that validates requests by checking that the client's Nebula IP matches DNS resolution of the requested domain, then uses knotc to add/remove TXT records via atomic zone transactions; a custom Caddy DNS plugin (caddy-dns-jakehillion) that communicates with this API; and replacement of NSD with Knot DNS for authoritative DNS to support dynamic updates. This eliminates the need for internal CA infrastructure while maintaining security through IP-based validation on the Nebula network. Test plan: - Built configuration with `nix build '.#nixosConfigurations."boron.cx.neb.jakehillion.me".config.system.build.toplevel'`
48 lines
937 B
Go
48 lines
937 B
Go
package jakehillion
|
|
|
|
import (
|
|
"github.com/caddyserver/caddy/v2"
|
|
"github.com/caddyserver/caddy/v2/caddyconfig/caddyfile"
|
|
)
|
|
|
|
func init() {
|
|
caddy.RegisterModule(Provider{})
|
|
}
|
|
|
|
// CaddyModule returns the Caddy module information.
|
|
func (Provider) CaddyModule() caddy.ModuleInfo {
|
|
return caddy.ModuleInfo{
|
|
ID: "dns.providers.jakehillion",
|
|
New: func() caddy.Module { return new(Provider) },
|
|
}
|
|
}
|
|
|
|
// UnmarshalCaddyfile sets up the DNS provider from Caddyfile tokens.
|
|
//
|
|
// Syntax:
|
|
//
|
|
// jakehillion {
|
|
// api_endpoint <url>
|
|
// }
|
|
func (p *Provider) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
|
|
for d.Next() {
|
|
for d.NextBlock(0) {
|
|
switch d.Val() {
|
|
case "api_endpoint":
|
|
if !d.NextArg() {
|
|
return d.ArgErr()
|
|
}
|
|
p.APIEndpoint = d.Val()
|
|
default:
|
|
return d.Errf("unrecognized subdirective: %s", d.Val())
|
|
}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Interface guards
|
|
var (
|
|
_ caddyfile.Unmarshaler = (*Provider)(nil)
|
|
)
|