Skip to content
Closed
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
13 changes: 7 additions & 6 deletions armor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 8 additions & 0 deletions http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions website/content/guide/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down