Skip to content

Commit ee32c62

Browse files
scottfeldmandeadprogram
authored andcommitted
crypto/tls: add Dialer.DialContext() to fix websocket client
The latest golang.org/x/net websocket package v0.33.0 needs Dialer.DailContext in crypto/tls. This PR adds it. Apps using golang.org/x/net are encouraged to use v0.33.0 to address: CVE-2024-45338: Non-linear parsing of case-insensitive content in golang.org/x/net/html CVE-2023-45288: net/http, x/net/http2: close connections when receiving too many headers Tested with examples/net/websocket/dial.
1 parent c482d35 commit ee32c62

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/crypto/tls/tls.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,13 @@ type Dialer struct {
101101
//
102102
// The returned Conn, if any, will always be of type *Conn.
103103
func (d *Dialer) DialContext(ctx context.Context, network, addr string) (net.Conn, error) {
104-
return nil, errors.New("tls:DialContext not implemented")
104+
switch network {
105+
case "tcp", "tcp4":
106+
default:
107+
return nil, fmt.Errorf("Network %s not supported", network)
108+
}
109+
110+
return net.DialTLS(addr)
105111
}
106112

107113
// LoadX509KeyPair reads and parses a public/private key pair from a pair

0 commit comments

Comments
 (0)