Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added custom ca provider #283

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,10 @@ ip = "0.0.0.0"
disable_registration = false
# listen port, eg. 443 for default HTTPS
port = "443"
# possible values: "letsencrypt", "letsencryptstaging", "cert", "none"
# possible values: "letsencrypt", "letsencryptstaging", "cert", "custom", "none"
tls = "letsencryptstaging"
# only used if tls = "custom"
tls_custom_url = "https://acme-v02.example.com/directory"
# only used if tls = "cert"
tls_cert_privkey = "/etc/tls/example.org/privkey.pem"
tls_cert_fullchain = "/etc/tls/example.org/fullchain.pem"
Expand Down
4 changes: 3 additions & 1 deletion config.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ ip = "0.0.0.0"
disable_registration = false
# listen port, eg. 443 for default HTTPS
port = "443"
# possible values: "letsencrypt", "letsencryptstaging", "cert", "none"
# possible values: "letsencrypt", "letsencryptstaging", "cert", "custom", "none"
tls = "letsencryptstaging"
# only used if tls = "custom"
tls_custom_url = "https://acme-v02.example.com/directory"
# only used if tls = "cert"
tls_cert_privkey = "/etc/tls/example.org/privkey.pem"
tls_cert_fullchain = "/etc/tls/example.org/fullchain.pem"
Expand Down
29 changes: 10 additions & 19 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build !test
//go:build !test

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This syntax is for go1.17 and later.

Given that acme-dns still claims to compile with go1.13, the original syntax should be maintained.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was done automaticlly by the IDE/go tools, i think the compatiblity should be ok since line 2 has the old syntax. I think its good to have both syntax supported since the old one may gets removed one day.

// +build !test

package main

Expand Down Expand Up @@ -160,25 +161,15 @@ func startHTTPAPI(errChan chan error, config DNSConfig, dnsservers []*DNSServer)

var err error
switch Config.API.TLS {
case "letsencryptstaging":
magicconf.CA = certmagic.LetsEncryptStagingCA
certcfg := certmagic.New(cache, magicconf)
err = certcfg.ManageSync([]string{Config.General.Domain})
if err != nil {
errChan <- err
return
}
cfg.GetCertificate = certcfg.GetCertificate
srv := &http.Server{
Addr: host,
Handler: c.Handler(api),
TLSConfig: cfg,
ErrorLog: stdlog.New(logwriter, "", 0),
case "letsencryptstaging", "letsencrypt", "custom":
switch Config.API.TLS {
case "letsencryptstaging":
magicconf.CA = certmagic.LetsEncryptStagingCA
case "letsencrypt":
magicconf.CA = certmagic.LetsEncryptProductionCA
case "custom":
magicconf.CA = Config.API.TLSCustomURL
}
log.WithFields(log.Fields{"host": host, "domain": Config.General.Domain}).Info("Listening HTTPS")
err = srv.ListenAndServeTLS("", "")
case "letsencrypt":
magicconf.CA = certmagic.LetsEncryptProductionCA
certcfg := certmagic.New(cache, magicconf)
err = certcfg.ManageSync([]string{Config.General.Domain})
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type httpapi struct {
AutocertPort string `toml:"autocert_port"`
Port string `toml:"port"`
TLS string
TLSCustomURL string `toml:"tls_custom_url"`
TLSCertPrivkey string `toml:"tls_cert_privkey"`
TLSCertFullchain string `toml:"tls_cert_fullchain"`
ACMECacheDir string `toml:"acme_cache_dir"`
Expand Down