Skip to content

Commit

Permalink
autocert: fix certmagic cache logging (#4134)
Browse files Browse the repository at this point in the history
  • Loading branch information
calebdoxsey authored and github-actions[bot] committed Apr 25, 2023
1 parent ba0aae3 commit 7be70c9
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions internal/autocert/manager.go
Expand Up @@ -76,24 +76,31 @@ func newManager(ctx context.Context,
return nil, err
}

certmagicConfig := certmagic.NewDefault()
// set certmagic default storage cache, otherwise cert renewal loop will be based off
// certmagic's own default location
certmagicConfig.Storage, err = GetCertMagicStorage(ctx, src.GetConfig().Options.AutocertOptions.Folder)
if err != nil {
return nil, err
}

logger := log.ZapLogger().With(zap.String("service", "autocert"))
certmagicConfig.Logger = logger
acmeTemplate.Logger = logger

mgr := &Manager{
src: src,
acmeTemplate: acmeTemplate,
certmagic: certmagicConfig,
ocspCache: ocspRespCache,
}

// set certmagic default storage cache, otherwise cert renewal loop will be based off
// certmagic's own default location
certmagicStorage, err := GetCertMagicStorage(ctx, src.GetConfig().Options.AutocertOptions.Folder)
if err != nil {
return nil, err
}
mgr.certmagic = certmagic.New(certmagic.NewCache(certmagic.CacheOptions{
GetConfigForCert: func(c certmagic.Certificate) (*certmagic.Config, error) {
return mgr.certmagic, nil
},
Logger: logger,
}), certmagic.Config{
Logger: logger,
Storage: certmagicStorage,
})

err = mgr.update(ctx, src.GetConfig())
if err != nil {
return nil, err
Expand Down

0 comments on commit 7be70c9

Please sign in to comment.