Skip to content

Commit

Permalink
Move the Let's Encrypt environment selection to proper place
Browse files Browse the repository at this point in the history
  • Loading branch information
joohoi committed Jan 25, 2022
1 parent 651de6f commit 3d42150
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,11 @@ func startHTTPAPI(errChan chan error, config DNSConfig, dnsservers []*DNSServer)
// Set up certmagic for getting certificate for acme-dns api
certmagic.DefaultACME.DNS01Solver = &provider
certmagic.DefaultACME.Agreed = true
certmagic.DefaultACME.CA = certmagic.LetsEncryptStagingCA
if Config.API.TLS == "letsencrypt" {
certmagic.DefaultACME.CA = certmagic.LetsEncryptProductionCA
} else {
certmagic.DefaultACME.CA = certmagic.LetsEncryptStagingCA
}
certmagic.DefaultACME.Email = Config.API.NotificationEmail
magicConf := certmagic.NewDefault()
magicConf.Storage = &storage
Expand All @@ -157,7 +161,6 @@ func startHTTPAPI(errChan chan error, config DNSConfig, dnsservers []*DNSServer)
var err error
switch Config.API.TLS {
case "letsencryptstaging":
certmagic.DefaultACME.CA = certmagic.LetsEncryptStagingCA
err = magic.ManageAsync(context.Background(), []string{Config.General.Domain})
if err != nil {
errChan <- err
Expand All @@ -174,7 +177,6 @@ func startHTTPAPI(errChan chan error, config DNSConfig, dnsservers []*DNSServer)
log.WithFields(log.Fields{"host": host, "domain": Config.General.Domain}).Info("Listening HTTPS")
err = srv.ListenAndServeTLS("", "")
case "letsencrypt":
certmagic.DefaultACME.CA = certmagic.LetsEncryptProductionCA
err = magic.ManageAsync(context.Background(), []string{Config.General.Domain})
if err != nil {
errChan <- err
Expand Down

0 comments on commit 3d42150

Please sign in to comment.