Skip to content

Commit 2f1e949

Browse files
Improve isTLSAlready check
All conn implementations having a Handshake() error method are now seen as a TLS conn and aren't wrapped in another tls.Client.
1 parent 404c8a8 commit 2f1e949

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

client.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1976,7 +1976,11 @@ func dialAddr(addr string, dial DialFunc, dialDualStack, isTLS bool, tlsConfig *
19761976
if conn == nil {
19771977
panic("BUG: DialFunc returned (nil, nil)")
19781978
}
1979-
_, isTLSAlready := conn.(*tls.Conn)
1979+
1980+
// We assume that any conn that has the Handshake() method is a TLS conn already.
1981+
// This doesn't cover just tls.Conn but also other TLS implementations.
1982+
_, isTLSAlready := conn.(interface{ Handshake() error })
1983+
19801984
if isTLS && !isTLSAlready {
19811985
if timeout == 0 {
19821986
return tls.Client(conn, tlsConfig), nil

0 commit comments

Comments
 (0)