Skip to content

Misleading OCSP warning logs despite no error #362

@aplr

Description

@aplr

What version of the package are you using?

v0.25.0

What are you trying to do?

Don't have misleading OCSP stapling logs.

While an attempt to fix it was taken in #353, it still did not catch all places where logs are produced.

What steps did you take?

Have OCSP enabled, with no actual errors produced.

What did you expect to happen, and what actually happened instead?

Expectation: No warning logs.

Reality: Tons of warning logs, with actually a nil error.

How do you think this should be fixed?

While this issue was correctly fixed here:

certmagic/certificates.go

Lines 349 to 356 in 20b57b0

err = stapleOCSP(ctx, cfg.OCSP, cfg.Storage, &cert, nil)
if err != nil {
if errors.Is(err, ErrNoOCSPServerSpecified) {
cfg.Logger.Debug("stapling OCSP", zap.Error(err))
} else {
cfg.Logger.Warn("stapling OCSP", zap.Error(err))
}
}

... this part still does a warning log even though the error is nil:

certmagic/certificates.go

Lines 435 to 440 in 20b57b0

err = stapleOCSP(ctx, cfg.OCSP, cfg.Storage, &cert, certPEMBlock)
if errors.Is(err, ErrNoOCSPServerSpecified) {
cfg.Logger.Debug("stapling OCSP", zap.Error(err), zap.Strings("identifiers", cert.Names))
} else {
cfg.Logger.Warn("stapling OCSP", zap.Error(err), zap.Strings("identifiers", cert.Names))
}

... and should rather look sth like this:

		err = stapleOCSP(ctx, cfg.OCSP, cfg.Storage, &cert, certPEMBlock)
		if errors.Is(err, ErrNoOCSPServerSpecified) {
			cfg.Logger.Debug("stapling OCSP", zap.Error(err), zap.Strings("identifiers", cert.Names))
		} else if err != nil {
			cfg.Logger.Warn("stapling OCSP", zap.Error(err), zap.Strings("identifiers", cert.Names))
		}

Please link to any related issues, pull requests, and/or discussion

#353

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions