mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
spdyroundtripper: d tlson't verify hostname twice
This commit is contained in:
parent
6d14c8e13f
commit
00a60426e7
@ -264,21 +264,11 @@ func (s *SpdyRoundTripper) tlsConn(ctx context.Context, rwc net.Conn, targetHost
|
|||||||
|
|
||||||
tlsConn := tls.Client(rwc, tlsConfig)
|
tlsConn := tls.Client(rwc, tlsConfig)
|
||||||
|
|
||||||
// need to manually call Handshake() so we can call VerifyHostname() below
|
|
||||||
if err := tlsConn.HandshakeContext(ctx); err != nil {
|
if err := tlsConn.HandshakeContext(ctx); err != nil {
|
||||||
tlsConn.Close()
|
tlsConn.Close()
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return if we were configured to skip validation
|
|
||||||
if tlsConfig.InsecureSkipVerify {
|
|
||||||
return tlsConn, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := tlsConn.VerifyHostname(tlsConfig.ServerName); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return tlsConn, nil
|
return tlsConn, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,23 +297,6 @@ func (s *SpdyRoundTripper) dialWithoutProxy(ctx context.Context, url *url.URL) (
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return if we were configured to skip validation
|
|
||||||
if s.tlsConfig != nil && s.tlsConfig.InsecureSkipVerify {
|
|
||||||
return conn, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
host, _, err := net.SplitHostPort(dialAddr)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if s.tlsConfig != nil && len(s.tlsConfig.ServerName) > 0 {
|
|
||||||
host = s.tlsConfig.ServerName
|
|
||||||
}
|
|
||||||
err = conn.VerifyHostname(host)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return conn, nil
|
return conn, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user