Skip to content

Commit 41f81ce

Browse files
committed
Demote stapling logs when no OCSP server specified (close #327)
1 parent e51e7ae commit 41f81ce

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

certificates.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"crypto/tls"
2020
"crypto/x509"
2121
"encoding/json"
22+
"errors"
2223
"fmt"
2324
"math/rand"
2425
"net"
@@ -346,7 +347,11 @@ func (cfg *Config) CacheUnmanagedTLSCertificate(ctx context.Context, tlsCert tls
346347
}
347348
err = stapleOCSP(ctx, cfg.OCSP, cfg.Storage, &cert, nil)
348349
if err != nil {
349-
cfg.Logger.Warn("stapling OCSP", zap.Error(err))
350+
if errors.Is(err, ErrNoOCSPServerSpecified) {
351+
cfg.Logger.Debug("stapling OCSP", zap.Error(err))
352+
} else {
353+
cfg.Logger.Warn("stapling OCSP", zap.Error(err))
354+
}
350355
}
351356
cfg.emit(ctx, "cached_unmanaged_cert", map[string]any{"sans": cert.Names})
352357
cert.Tags = tags
@@ -394,7 +399,9 @@ func (cfg Config) makeCertificateWithOCSP(ctx context.Context, certPEMBlock, key
394399
return cert, err
395400
}
396401
err = stapleOCSP(ctx, cfg.OCSP, cfg.Storage, &cert, certPEMBlock)
397-
if err != nil {
402+
if errors.Is(err, ErrNoOCSPServerSpecified) {
403+
cfg.Logger.Debug("stapling OCSP", zap.Error(err), zap.Strings("identifiers", cert.Names))
404+
} else {
398405
cfg.Logger.Warn("stapling OCSP", zap.Error(err), zap.Strings("identifiers", cert.Names))
399406
}
400407
return cert, nil

handshake.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,11 @@ func (cfg *Config) handshakeMaintenance(ctx context.Context, hello *tls.ClientHe
599599
if err != nil {
600600
// An error with OCSP stapling is not the end of the world, and in fact, is
601601
// quite common considering not all certs have issuer URLs that support it.
602-
logger.Warn("stapling OCSP", zap.Error(err))
602+
if errors.Is(err, ErrNoOCSPServerSpecified) {
603+
logger.Debug("stapling OCSP", zap.Error(err))
604+
} else {
605+
logger.Warn("stapling OCSP", zap.Error(err))
606+
}
603607
} else {
604608
logger.Debug("successfully stapled new OCSP response",
605609
zap.Int("ocsp_status", cert.ocsp.Status),

0 commit comments

Comments
 (0)