Skip to content

Commit 66c0eb5

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 66c0eb5

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

listenbrainz/listenbrainz.go

Lines changed: 11 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,16 @@ 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+
CurvePreferences: []tls.CurveID{tls.X25519, tls.CurveP256, tls.CurveP384},
41+
},
42+
},
43+
})
3444
}
3545

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

0 commit comments

Comments
 (0)