mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-06 10:21:05 +02:00
autocert: use new OCSP error type (#4437)
This commit is contained in:
parent
9d4d31cb4f
commit
0affd9268b
2 changed files with 7 additions and 4 deletions
|
@ -1,8 +1,9 @@
|
||||||
package autocert
|
package autocert
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"errors"
|
||||||
|
|
||||||
|
"github.com/caddyserver/certmagic"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"go.uber.org/zap/zapcore"
|
"go.uber.org/zap/zapcore"
|
||||||
|
|
||||||
|
@ -32,7 +33,7 @@ func (c certMagicLoggerCore) Check(e zapcore.Entry, ce *zapcore.CheckedEntry) *z
|
||||||
func (c certMagicLoggerCore) Write(e zapcore.Entry, fs []zapcore.Field) error {
|
func (c certMagicLoggerCore) Write(e zapcore.Entry, fs []zapcore.Field) error {
|
||||||
fs = append(c.fields, fs...)
|
fs = append(c.fields, fs...)
|
||||||
for _, f := range fs {
|
for _, f := range fs {
|
||||||
if f.Type == zapcore.ErrorType && strings.Contains(f.Interface.(error).Error(), "no OCSP server specified in certificate") {
|
if f.Type == zapcore.ErrorType && errors.Is(f.Interface.(error), certmagic.ErrNoOCSPServerSpecified) {
|
||||||
// ignore this error message (#4245)
|
// ignore this error message (#4245)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,10 @@ package autocert
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/caddyserver/certmagic"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"go.uber.org/zap/zapcore"
|
"go.uber.org/zap/zapcore"
|
||||||
|
@ -20,7 +21,8 @@ func TestCertMagicLogger(t *testing.T) {
|
||||||
|
|
||||||
logger := zap.New(core)
|
logger := zap.New(core)
|
||||||
|
|
||||||
logger.Info("TEST", zap.Error(errors.New("no OCSP server specified in certificate")))
|
ocspError := fmt.Errorf("ocsp error: %w", certmagic.ErrNoOCSPServerSpecified)
|
||||||
|
logger.Info("TEST", zap.Error(ocspError))
|
||||||
assert.Empty(t, buf.Bytes())
|
assert.Empty(t, buf.Bytes())
|
||||||
|
|
||||||
logger.Info("TEST")
|
logger.Info("TEST")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue