Skip to content

Commit

Permalink
Merge pull request #656 from adotkhan/utls-fix
Browse files Browse the repository at this point in the history
Fixed TestSelectTLSProfile
  • Loading branch information
rod-hynes authored Sep 12, 2023
2 parents 728964f + e2be6e3 commit ebd4fdc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
10 changes: 5 additions & 5 deletions psiphon/common/protocol/customTLSProfiles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,26 @@ func TestCustomTLSProfiles(t *testing.T) {
&utls.ALPNExtension{AlpnProtocols: []string{"h2", "http/1.1"}},
&utls.FakeChannelIDExtension{},
&utls.SupportedPointsExtension{SupportedPoints: []byte{0}},
&utls.SupportedCurvesExtension{[]utls.CurveID{
&utls.SupportedCurvesExtension{Curves: []utls.CurveID{
utls.X25519, utls.CurveP256, utls.CurveP384}},
&utls.UtlsPaddingExtension{GetPaddingLen: utls.BoringPaddingStyle},

// Additional extensions for test coverage
&utls.NPNExtension{NextProtos: []string{"http/1.1"}},
&utls.GenericExtension{Id: 9999, Data: []byte("generic extension")},
&utls.KeyShareExtension{[]utls.KeyShare{
&utls.KeyShareExtension{KeyShares: []utls.KeyShare{
{Group: utls.X25519, Data: []byte{9, 9, 9, 9}},
}},
&utls.PSKKeyExchangeModesExtension{[]uint8{
&utls.PSKKeyExchangeModesExtension{Modes: []uint8{
utls.PskModeDHE,
}},
&utls.SupportedVersionsExtension{[]uint16{
&utls.SupportedVersionsExtension{Versions: []uint16{
utls.VersionTLS13,
utls.VersionTLS12,
utls.VersionTLS11,
utls.VersionTLS10,
}},
&utls.UtlsCompressCertExtension{[]utls.CertCompressionAlgo{
&utls.UtlsCompressCertExtension{Algorithms: []utls.CertCompressionAlgo{
utls.CertCompressionBrotli,
}},
&utls.FakeChannelIDExtension{},
Expand Down
4 changes: 2 additions & 2 deletions psiphon/tlsDialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ func getUTLSClientHelloID(
case protocol.TLS_PROFILE_CHROME_112_PSK:
preset, err := utls.UTLSIdToSpec(utls.HelloChrome_112_PSK_Shuf)
if err != nil {
return utls.HelloCustom, nil, err
return utls.ClientHelloID{}, nil, err
}

// Generates typical PSK extension values.
Expand Down Expand Up @@ -902,7 +902,7 @@ func getUTLSClientHelloID(

customTLSProfile := p.CustomTLSProfile(tlsProfile)
if customTLSProfile == nil {
return utls.HelloCustom,
return utls.ClientHelloID{},
nil,
errors.Tracef("unknown TLS profile: %s", tlsProfile)
}
Expand Down
4 changes: 3 additions & 1 deletion psiphon/tlsDialer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,9 @@ func TestSelectTLSProfile(t *testing.T) {
}

var unexpectedClientHelloID, unexpectedClientHelloSpec bool
if i < len(protocol.SupportedTLSProfiles) {

// TLS_PROFILE_CHROME_112_PSK profile is a special case. Check getUTLSClientHelloID for details.
if i < len(protocol.SupportedTLSProfiles) && profile != protocol.TLS_PROFILE_CHROME_112_PSK {
if utlsClientHelloID == utls.HelloCustom {
unexpectedClientHelloID = true
}
Expand Down

0 comments on commit ebd4fdc

Please sign in to comment.