Skip to content

Commit b2674f8

Browse files
committed
fix(listenbrainz): disable post-quantum TLS to avoid connection reset errors
listenbrainz's server can't handle the larger TLS ClientHello from Go's post-quantum key exchange (Kyber). Explicitly set classic curve preferences to avoid "connection reset by peer" errors. golang/go#70139
1 parent 4fff418 commit b2674f8

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

listenbrainz/listenbrainz.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package listenbrainz
22

33
import (
44
"bytes"
5+
"crypto/tls"
56
"encoding/json"
67
"errors"
78
"fmt"
@@ -30,7 +31,17 @@ type Client struct {
3031
}
3132

3233
func NewClient() *Client {
33-
return NewClientCustom(http.DefaultClient)
34+
// disable post-quantum key exchange (Kyber) to avoid "connection reset by peer" errors.
35+
// listenbrainz's server can't handle the larger TLS ClientHello
36+
// https://github.com/golang/go/issues/70139
37+
return NewClientCustom(&http.Client{
38+
Transport: &http.Transport{
39+
TLSClientConfig: &tls.Config{
40+
MinVersion: tls.VersionTLS12,
41+
CurvePreferences: []tls.CurveID{tls.X25519, tls.CurveP256, tls.CurveP384},
42+
},
43+
},
44+
})
3445
}
3546

3647
func NewClientCustom(httpClient *http.Client) *Client {

0 commit comments

Comments
 (0)