diff --git a/armor.go b/armor.go index ac8a233..0e13716 100644 --- a/armor.go +++ b/armor.go @@ -35,12 +35,13 @@ type ( } TLS struct { - Address string `yaml:"address"` - CertFile string `yaml:"cert_file"` - KeyFile string `yaml:"key_file"` - Auto bool `yaml:"auto"` - CacheDir string `yaml:"cache_dir"` - Email string `yaml:"email"` + Address string `yaml:"address"` + CertFile string `yaml:"cert_file"` + KeyFile string `yaml:"key_file"` + Auto bool `yaml:"auto"` + CacheDir string `yaml:"cache_dir"` + Email string `yaml:"email"` + DirectoryURL string `yaml:"directory_url"` } Admin struct { diff --git a/http/http.go b/http/http.go index 64c42a4..b762cde 100644 --- a/http/http.go +++ b/http/http.go @@ -11,6 +11,7 @@ import ( "github.com/labstack/echo" "github.com/labstack/gommon/log" homedir "github.com/mitchellh/go-homedir" + "golang.org/x/crypto/acme" "golang.org/x/crypto/acme/autocert" ) @@ -46,6 +47,10 @@ func Init(a *armor.Armor) (h *HTTP) { WriteTimeout: a.WriteTimeout * time.Second, } e.AutoTLSManager.Email = a.TLS.Email + e.AutoTLSManager.Client = new(acme.Client) + if a.TLS.DirectoryURL != "" { + e.AutoTLSManager.Client.DirectoryURL = a.TLS.DirectoryURL + } } e.Logger = h.logger @@ -90,6 +95,9 @@ func (h *HTTP) StartTLS() error { s.TLSConfig.NextProtos = append(s.TLSConfig.NextProtos, "h2") if a.TLS.Auto { + // Enable the "http-01" challenge + e.Server.Handler = e.AutoTLSManager.HTTPHandler(e.Server.Handler) + hosts := []string{} for host := range a.Hosts { hosts = append(hosts, host) diff --git a/website/content/guide/configuration.md b/website/content/guide/configuration.md index 399b3e0..774f9f1 100644 --- a/website/content/guide/configuration.md +++ b/website/content/guide/configuration.md @@ -28,6 +28,7 @@ Name | Type | Description `auto` | bool | Enable automatic certificates from https://letsencrypt.org `cache_dir` | string | Cache directory to store certificates from https://letsencrypt.org. Default value `~/.armor/cache`. `email` | string | Email optionally specifies a contact email address. +`directory_url` | string | Defines the ACME CA directory endpoint. If empty, LetsEncryptURL is used (acme.LetsEncryptURL). `hosts`