Skip to content

Commit a2cdfb4

Browse files
k8s-ci-robotipochi
authored andcommitted
Merge pull request kubernetes-sigs#749 from JanHolger/fix-panic-without-mtls
Fix panic when mtls is disabled (cherry picked from commit e135055)
1 parent a6c1ccc commit a2cdfb4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pkg/server/tunnel.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func (t *Tunnel) ServeHTTP(w http.ResponseWriter, r *http.Request) {
4040
defer metrics.Metrics.HTTPConnectionDec()
4141

4242
klog.V(2).InfoS("Received request for host", "method", r.Method, "host", r.Host, "userAgent", r.UserAgent())
43-
if r.TLS != nil {
43+
if r.TLS != nil && len(r.TLS.PeerCertificates) > 0 {
4444
klog.V(2).InfoS("TLS", "commonName", r.TLS.PeerCertificates[0].Subject.CommonName)
4545
}
4646
if r.Method != http.MethodConnect {

0 commit comments

Comments
 (0)