From 34ef9fa0dcc377234390a8307f27401e45f5d1fc Mon Sep 17 00:00:00 2001 From: Jan Bebendorf Date: Wed, 4 Jun 2025 17:17:13 +0000 Subject: [PATCH] fix: prevent panic when mtls is disabled --- pkg/server/tunnel.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/server/tunnel.go b/pkg/server/tunnel.go index 3d3ec18d2..1f25b3169 100644 --- a/pkg/server/tunnel.go +++ b/pkg/server/tunnel.go @@ -40,7 +40,7 @@ func (t *Tunnel) ServeHTTP(w http.ResponseWriter, r *http.Request) { defer metrics.Metrics.HTTPConnectionDec() klog.V(2).InfoS("Received request for host", "method", r.Method, "host", r.Host, "userAgent", r.UserAgent()) - if r.TLS != nil { + if r.TLS != nil && len(r.TLS.PeerCertificates) > 0 { klog.V(2).InfoS("TLS", "commonName", r.TLS.PeerCertificates[0].Subject.CommonName) } if r.Method != http.MethodConnect {