fixup some acme related things

This commit is contained in:
Asim Aslam 2019-10-23 22:15:15 +01:00
parent 82f94c7861
commit 3fc04f4dff
3 changed files with 16 additions and 20 deletions

View File

@ -13,7 +13,7 @@ import (
)
type certmagicProvider struct {
opts *acme.Options
opts acme.Options
}
func (c *certmagicProvider) NewListener(ACMEHosts ...string) (net.Listener, error) {
@ -40,23 +40,19 @@ func (c *certmagicProvider) NewListener(ACMEHosts ...string) (net.Listener, erro
// New returns a certmagic provider
func New(options ...acme.Option) acme.Provider {
o := &acme.Options{}
if len(options) == 0 {
for _, op := range acme.Default() {
op(o)
opts := acme.DefaultOptions()
for _, o := range options {
o(&opts)
}
} else {
for _, op := range options {
op(o)
}
}
if o.Cache != nil {
if _, ok := o.Cache.(certmagic.Storage); !ok {
if opts.Cache != nil {
if _, ok := opts.Cache.(certmagic.Storage); !ok {
log.Fatal("ACME: cache provided doesn't implement certmagic's Storage interface")
}
}
return &certmagicProvider{
opts: o,
opts: opts,
}
}

View File

@ -89,7 +89,7 @@ func (s *storage) Exists(key string) bool {
}
func (s *storage) List(prefix string, recursive bool) ([]string, error) {
records, err := s.store.Sync()
records, err := s.store.List()
if err != nil {
return nil, err
}

View File

@ -63,11 +63,11 @@ func Cache(c interface{}) Option {
}
}
// Default uses the Let's Encrypt Production CA, with DNS Challenge disabled.
func Default() []Option {
return []Option{
AcceptToS(true),
CA(LetsEncryptProductionCA),
OnDemand(true),
// DefaultOptions uses the Let's Encrypt Production CA, with DNS Challenge disabled.
func DefaultOptions() Options {
return Options{
AcceptToS: true,
CA: LetsEncryptProductionCA,
OnDemand: true,
}
}