tls: Asynchronous cert management at startup (uses CertMagic v0.8.0)

This commit is contained in:
Matthew Holt 2019-10-16 15:20:27 -06:00
parent a458544d9f
commit bce2edd22d
No known key found for this signature in database
GPG key ID: 2A349DD577D586A5
3 changed files with 10 additions and 2 deletions

2
go.mod
View file

@ -14,7 +14,7 @@ require (
github.com/klauspost/compress v1.8.6 github.com/klauspost/compress v1.8.6
github.com/klauspost/cpuid v1.2.1 github.com/klauspost/cpuid v1.2.1
github.com/lucas-clemente/quic-go v0.12.1 github.com/lucas-clemente/quic-go v0.12.1
github.com/mholt/certmagic v0.7.5 github.com/mholt/certmagic v0.8.0
github.com/muhammadmuzzammil1998/jsonc v0.0.0-20190906142622-1265e9b150c6 github.com/muhammadmuzzammil1998/jsonc v0.0.0-20190906142622-1265e9b150c6
github.com/rs/cors v1.7.0 github.com/rs/cors v1.7.0
github.com/russross/blackfriday/v2 v2.0.1 github.com/russross/blackfriday/v2 v2.0.1

2
go.sum
View file

@ -172,6 +172,8 @@ github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzp
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-tty v0.0.0-20180219170247-931426f7535a/go.mod h1:XPvLUNfbS4fJH25nqRHfWLMa1ONC8Amw+mIA639KxkE= github.com/mattn/go-tty v0.0.0-20180219170247-931426f7535a/go.mod h1:XPvLUNfbS4fJH25nqRHfWLMa1ONC8Amw+mIA639KxkE=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/mholt/certmagic v0.8.0 h1:WEQhZ4+ySd2cQz0Gf1iEk6xsUaEmmHe10SZiiKd7BdY=
github.com/mholt/certmagic v0.8.0/go.mod h1:91uJzK5K8IWtYQqTi5R2tsxV1pCde+wdGfaRaOZi6aQ=
github.com/miekg/dns v1.1.15 h1:CSSIDtllwGLMoA6zjdKnaE6Tx6eVUxQ29LUgGetiDCI= github.com/miekg/dns v1.1.15 h1:CSSIDtllwGLMoA6zjdKnaE6Tx6eVUxQ29LUgGetiDCI=
github.com/miekg/dns v1.1.15/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.1.15/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ= github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ=

View file

@ -189,7 +189,12 @@ func (t *TLS) Manage(names []string) error {
for _, name := range names { for _, name := range names {
ap := t.getAutomationPolicyForName(name) ap := t.getAutomationPolicyForName(name)
magic := certmagic.New(t.certCache, ap.makeCertMagicConfig(t.ctx)) magic := certmagic.New(t.certCache, ap.makeCertMagicConfig(t.ctx))
err := magic.Manage([]string{name}) var err error
if ap.ManageSync {
err = magic.ManageSync([]string{name})
} else {
err = magic.ManageAsync(t.ctx.Context, []string{name})
}
if err != nil { if err != nil {
return fmt.Errorf("automate: manage %s: %v", name, err) return fmt.Errorf("automate: manage %s: %v", name, err)
} }
@ -317,6 +322,7 @@ type AutomationConfig struct {
type AutomationPolicy struct { type AutomationPolicy struct {
Hosts []string `json:"hosts,omitempty"` Hosts []string `json:"hosts,omitempty"`
ManagementRaw json.RawMessage `json:"management,omitempty"` ManagementRaw json.RawMessage `json:"management,omitempty"`
ManageSync bool `json:"manage_sync,omitempty"`
Management ManagerMaker `json:"-"` Management ManagerMaker `json:"-"`
} }