Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autocert: fix certmagic cache logging #4134

Merged
merged 1 commit into from Apr 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 17 additions & 10 deletions internal/autocert/manager.go
Expand Up @@ -77,24 +77,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