Skip to content

[Bug]: remote error: tls: unexpected message #192

@ohpder

Description

@ohpder

TLS client version

latest

System information

Windows 10 Intel 13900K

Issue description

remote error: tls: unexpected message

Steps to reproduce / Code Sample

package main

import (
"github.com/bogdanfinn/fhttp/http2"
tls_client "github.com/bogdanfinn/tls-client"
"github.com/bogdanfinn/tls-client/profiles"
tls "github.com/bogdanfinn/utls"
)

func testTLSHandshake() {
TencentAid1Custom := profiles.NewClientProfile(
tls.ClientHelloID{
Client: "Chrome",
Version: "43",
Seed: nil,
SpecFactory: func() (tls.ClientHelloSpec, error) {
return tls.ClientHelloSpec{
CipherSuites: []uint16{
tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
tls.FAKE_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,
tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
tls.FAKE_OLD_TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
tls.FAKE_TLS_DHE_RSA_WITH_AES_256_CBC_SHA,
tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
51,
tls.TLS_RSA_WITH_AES_128_GCM_SHA256,
tls.TLS_RSA_WITH_AES_256_CBC_SHA,
tls.TLS_RSA_WITH_AES_128_CBC_SHA,
tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA,
255,
},
// CompressionMethods is not implemented by tls.peet.ws, check manually
CompressionMethods: []uint8{
tls.CompressionNone,
},
Extensions: []tls.TLSExtension{
&tls.SNIExtension{},
&tls.ExtendedMasterSecretExtension{},
&tls.SessionTicketExtension{},
&tls.SignatureAlgorithmsExtension{SupportedSignatureAlgorithms: []tls.SignatureScheme{
tls.PKCS1WithSHA512,
tls.ECDSAWithP521AndSHA512,
tls.PKCS1WithSHA384,
tls.ECDSAWithP384AndSHA384,
tls.PKCS1WithSHA256,
tls.ECDSAWithP256AndSHA256,
tls.SHA224_RSA,
tls.SHA224_ECDSA,
tls.PKCS1WithSHA1,
tls.ECDSAWithSHA1,
}},
&tls.StatusRequestExtension{},
&tls.NPNExtension{},
&tls.SCTExtension{},
&tls.FakeChannelIDExtension{},
&tls.SupportedPointsExtension{SupportedPoints: []uint8{
tls.PointFormatUncompressed,
}},
&tls.SupportedCurvesExtension{Curves: []tls.CurveID{
tls.CurveP256,
tls.CurveP384,
}},
&tls.UtlsPaddingExtension{GetPaddingLen: tls.BoringPaddingStyle},
},
}, nil
},
},
map[http2.SettingID]uint32{
http2.SettingHeaderTableSize: 65536,
http2.SettingEnablePush: 0,
http2.SettingInitialWindowSize: 6291456,
http2.SettingMaxHeaderListSize: 262144,
},
[]http2.SettingID{
http2.SettingHeaderTableSize,
http2.SettingEnablePush,
http2.SettingInitialWindowSize,
http2.SettingMaxHeaderListSize,
},
[]string{
":method",
":path",
":authority",
":scheme",
},
15663105, nil, nil,
)
TencentAid1Custom.GetClientHelloId()
options := []tls_client.HttpClientOption{
tls_client.WithDefaultHeaders(map[string][]string{
"User-Agent": {"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36"},
}),
tls_client.WithRandomTLSExtensionOrder(),
tls_client.WithClientProfile(TencentAid1Custom),
tls_client.WithDebug(),
}

client, _ := tls_client.NewHttpClient(tls_client.NewNoopLogger(), options...)

resp, _ := client.Get("https://tls.peet.ws/api/all")
println(resp.StatusCode)
resp, _ = client.Get("https://t.captcha.qq.com/cap_union_prehandle?aid=188907622&protocol=https&accver=1&showtype=popup&ua=TW96aWxsYS81LjAgKFdpbmRvd3MgTlQgNi4yOyBXT1c2NCkgQXBwbGVXZWJLaXQvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgUVEvOS43LjI1LjI5NDExIENocm9tZS80My4wLjIzNTcuMTM0IFNhZmFyaS81MzcuMzYgUUJDb3JlLzMuNDMuMTI5OC40MDAgUVFCcm93c2VyLzkuMC4yNTI0LjQwMA==&noheader=1&fb=1&aged=0&enableAged=0&enableDarkMode=0&sid=&grayscale=1&dyeid=0&clientype=2&userLanguage=zh-cn&cap_cd=&uid=&lang=zh-cn&entry_url=http://localhost:63342/&elder_captcha=0&js=%2Ftcaptcha-frame.8d77d8b0.js&login_appid=&wb=1&version=1.1.0&subsid=1&callback=_aq_93640&sess=")
println(resp.StatusCode)

}

func main() {
testTLSHandshake()
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions