From d8aec6f4d94bddfe0db12fe55f443a4b3c4f19a3 Mon Sep 17 00:00:00 2001 From: Alexandre Stein Date: Mon, 5 Mar 2018 14:34:44 +0100 Subject: [PATCH 1/2] Fixes #30 --- http/http.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/http/http.go b/http/http.go index 64c42a4..a0c0e29 100644 --- a/http/http.go +++ b/http/http.go @@ -90,6 +90,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) From 7af48c43fef0b856a28c873ba96a401e925cdcae Mon Sep 17 00:00:00 2001 From: Alexandre Stein Date: Mon, 5 Mar 2018 15:13:24 +0100 Subject: [PATCH 2/2] Add configuration for a specific ACME endpoint --- armor.go | 13 +++++++------ http/http.go | 5 +++++ website/content/guide/configuration.md | 1 + 3 files changed, 13 insertions(+), 6 deletions(-) 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 a0c0e29..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 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`