diff options
author | Alan Pearce | 2024-11-27 15:06:04 +0100 |
---|---|---|
committer | Alan Pearce | 2024-11-27 15:06:04 +0100 |
commit | 8ecb3549518646e39ec7df0079ae6cad3384271a (patch) | |
tree | 18ca08745b6d87b2ecf897667ea53ff4eda6b49d | |
parent | 72018b5585e945aa51a3a557a641cce17cabaf26 (diff) | |
download | website-8ecb3549518646e39ec7df0079ae6cad3384271a.tar.lz website-8ecb3549518646e39ec7df0079ae6cad3384271a.tar.zst website-8ecb3549518646e39ec7df0079ae6cad3384271a.zip |
Use PowerDNS API instead of acme-dns (buggy)
-rw-r--r-- | fly.toml | 3 | ||||
-rw-r--r-- | go.mod | 3 | ||||
-rw-r--r-- | go.sum | 11 | ||||
-rw-r--r-- | internal/server/tls.go | 19 |
4 files changed, 18 insertions, 18 deletions
diff --git a/fly.toml b/fly.toml index 5c35318..024d3ef 100644 --- a/fly.toml +++ b/fly.toml @@ -16,9 +16,10 @@ primary_region = "ams" TLS = "true" ROOT = "/data" PRODUCTION = "true" + POWERDNS_SERVER_URL = "https://pdns.alanpearce.eu" + # POWERDNS_API_TOKEN = "from fly secret" VCS_LOCAL_PATH = "/data/website" VCS_REMOTE_URL = "https://git.alanpearce.eu/website.git" - ACME_SERVER_URL = "https://acme.alanpearce.eu" GOMEMLIMIT = "128MiB" [[services]] diff --git a/go.mod b/go.mod index 05193df..5a281f6 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/fsnotify/fsnotify v1.7.0 github.com/go-git/go-git/v5 v5.12.0 github.com/kevinpollet/nego v0.0.0-20211010160919-a65cd48cee43 - github.com/libdns/acmedns v0.2.0 + github.com/libdns/powerdns v0.1.3 github.com/osdevisnot/sorvor v0.4.4 github.com/pberkel/caddy-storage-redis v1.2.0 github.com/snabb/sitemap v1.0.4 @@ -67,6 +67,7 @@ require ( github.com/mholt/acmez/v2 v2.0.2 // indirect github.com/microcosm-cc/bluemonday v1.0.26 // indirect github.com/miekg/dns v1.1.62 // indirect + github.com/mittwald/go-powerdns v0.6.6 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/onsi/ginkgo/v2 v2.20.2 // indirect github.com/pjbgf/sha1cd v0.3.0 // indirect diff --git a/go.sum b/go.sum index 2d264cb..4e0b044 100644 --- a/go.sum +++ b/go.sum @@ -118,6 +118,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8= github.com/gorilla/css v1.0.1/go.mod h1:BvnYkspnSzMmwRK+b8/xgNPLiIuNZr6vbZBTPQ2A3b0= +github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw= +github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= @@ -138,18 +140,21 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/libdns/acmedns v0.2.0 h1:zTXdHZwe3r2issdVRyqt5/4X2yHpiBVmFnTrwBA29ik= -github.com/libdns/acmedns v0.2.0/go.mod h1:XlKHilQQK/IGHYY//vCb903PdG4Wc/XnDQzcMp2hV3g= github.com/libdns/libdns v0.2.2 h1:O6ws7bAfRPaBsgAYt8MDe2HcNBGC29hkZ9MX2eUSX3s= github.com/libdns/libdns v0.2.2/go.mod h1:4Bj9+5CQiNMVGf87wjX4CY3HQJypUHRuLvlsfsZqLWQ= +github.com/libdns/powerdns v0.1.3 h1:rRD/P0g/9Ru8cu4eGxiLp8GrMZTkj+BnNwIevTkUphM= +github.com/libdns/powerdns v0.1.3/go.mod h1:xUy794+JpPeN9tM6PC1JITdetgRfRnPH1UFTrd2Eu2Y= github.com/mholt/acmez/v2 v2.0.2 h1:OmK6xckte2JfKGPz4OAA8aNHTiLvGp8tLzmrd/wfSyw= github.com/mholt/acmez/v2 v2.0.2/go.mod h1:fX4c9r5jYwMyMsC+7tkYRxHibkOTgta5DIFGoe67e1U= github.com/microcosm-cc/bluemonday v1.0.26 h1:xbqSvqzQMeEHCqMi64VAs4d8uy6Mequs3rQ0k/Khz58= github.com/microcosm-cc/bluemonday v1.0.26/go.mod h1:JyzOCs9gkyQyjs+6h10UEVSe02CGwkhd72Xdqh78TWs= github.com/miekg/dns v1.1.62 h1:cN8OuEF1/x5Rq6Np+h1epln8OiyPWV+lROx9LxcGgIQ= github.com/miekg/dns v1.1.62/go.mod h1:mvDlcItzm+br7MToIKqkglaGhlFMHJ9DTNNWONWXbNQ= +github.com/mittwald/go-powerdns v0.6.6 h1:yQcuszhl98+jJgELjD5ecfxCQWoshhnArexpwrwQxLY= +github.com/mittwald/go-powerdns v0.6.6/go.mod h1:adWJ860laOgm14afg+7V0nCa5NQT37oEYe2HRhoS/CA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms= github.com/onsi/ginkgo/v2 v2.20.2 h1:7NVCeyIWROIAheY21RLS+3j2bb52W0W82tkberYytp4= github.com/onsi/ginkgo/v2 v2.20.2/go.mod h1:K9gyxPIlb+aIvnZ8bd9Ak+YP18w3APlR+5coaZoE2ag= github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k= @@ -364,6 +369,8 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/h2non/gock.v1 v1.0.14 h1:fTeu9fcUvSnLNacYvYI54h+1/XEteDyHvrVCZEEEYNM= +gopkg.in/h2non/gock.v1 v1.0.14/go.mod h1:sX4zAkdYX1TRGJ2JY156cFspQn4yRWn6p9EMdODlynE= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/internal/server/tls.go b/internal/server/tls.go index 9f22a5e..1c1073e 100644 --- a/internal/server/tls.go +++ b/internal/server/tls.go @@ -13,7 +13,7 @@ import ( "github.com/ardanlabs/conf/v3" "github.com/caddyserver/caddy/v2" "github.com/caddyserver/certmagic" - "github.com/libdns/acmedns" + "github.com/libdns/powerdns" certmagic_redis "github.com/pberkel/caddy-storage-redis" "gitlab.com/tozd/go/errors" ) @@ -26,13 +26,6 @@ type redisConfig struct { KeyPrefix string `conf:"default:certmagic"` } -type acmeConfig struct { - Username string `conf:"required"` - Password string `conf:"required"` - Subdomain string `conf:"required"` - ServerURL string `conf:"env:SERVER_URL,default:https://acme.alanpearce.eu"` -} - func (s *Server) serveTLS() (err error) { log := s.log.Named("tls") @@ -81,10 +74,10 @@ func (s *Server) serveTLS() (err error) { return errors.Wrap(err, "could not parse redis config") } - acme := &acmedns.Provider{} - _, err = conf.Parse("ACME", acme) + pdns := &powerdns.Provider{} + _, err = conf.Parse("POWERDNS", pdns) if err != nil { - return errors.Wrap(err, "could not parse ACME config") + return errors.Wrap(err, "could not parse PowerDNS ACME config") } issuer = certmagic.NewACMEIssuer(cfg, certmagic.ACMEIssuer{ @@ -94,7 +87,7 @@ func (s *Server) serveTLS() (err error) { Logger: certmagic.Default.Logger, DNS01Solver: &certmagic.DNS01Solver{ DNSManager: certmagic.DNSManager{ - DNSProvider: acme, + DNSProvider: pdns, Logger: certmagic.Default.Logger, }, }, @@ -102,8 +95,6 @@ func (s *Server) serveTLS() (err error) { certificateDomains = append(slices.Clone(s.config.Domains), wildcardDomain) - log.Info("acme", "username", acme.Username, "subdomain", acme.Subdomain, "server_url", acme.ServerURL) - rs := certmagic_redis.New() rs.Address = []string{rc.Address} rs.Username = rc.Username |