fix(entrypoint): log global inbound mTLS errors instead of panicking

When resolveInboundMTLSProfileForRoute fails for the global profile, emit a
zerolog error and continue without applying that pool. Apply inbound mTLS from
the global profile only when err is nil and pool is non-nil.

Add yaml struct tags to InboundMTLSProfile alongside json for YAML config
loading.

Clarify no-op stub methods in inbound_mtls_validation_test with comments.
This commit is contained in:
yusing
2026-04-13 17:14:58 +08:00
parent 2a6ad90b72
commit b082d6dc77
3 changed files with 12 additions and 10 deletions

View File

@@ -7,6 +7,7 @@ import (
"fmt"
"os"
"github.com/rs/zerolog/log"
"github.com/yusing/godoxy/internal/types"
gperr "github.com/yusing/goutils/errs"
)
@@ -88,9 +89,9 @@ func (srv *httpServer) mutateServerTLSConfig(base *tls.Config) *tls.Config {
}
pool, err := srv.resolveInboundMTLSProfileForRoute(nil)
if err != nil {
panic(err)
log.Err(err).Msg("inbound mTLS: failed to resolve global profile, falling back to per-route mTLS")
}
if pool != nil {
if pool != nil && err == nil {
return applyInboundMTLSProfile(base, pool)
}