Skip to content

Commit 621b7e9

Browse files
authored
Move cfg nil check from RenewManagedCertificates to getConfig (#348)
getConfig checks cfg.certCache so cfg can never be nil inside of getConfig or it can crash with: invalid memory address or nil pointer dereference
1 parent 17fb245 commit 621b7e9

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

cache.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,10 @@ func (certCache *Cache) getConfig(cert Certificate) (*Config, error) {
365365
if err != nil {
366366
return nil, err
367367
}
368+
if cfg == nil {
369+
// this is bad if this happens, probably a programmer error (oops)
370+
return nil, fmt.Errorf("no configuration associated with certificate: %v;", cert.Names)
371+
}
368372
if cfg.certCache == nil {
369373
return nil, fmt.Errorf("config returned for certificate %v has nil cache; expected %p (this one)",
370374
cert.Names, certCache)

maintain.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,6 @@ func (certCache *Cache) RenewManagedCertificates(ctx context.Context) error {
125125
zap.Error(err))
126126
continue
127127
}
128-
if cfg == nil {
129-
// this is bad if this happens, probably a programmer error (oops)
130-
log.Error("no configuration associated with certificate; unable to manage",
131-
zap.Strings("identifiers", cert.Names))
132-
continue
133-
}
134128
if cfg.OnDemand != nil {
135129
continue
136130
}

0 commit comments

Comments
 (0)