netxlite: utls for TLS parroting

This is the ground work for https://github.com/ooni/probe/issues/1424.
This commit is contained in:
kelmenhorst 2021-07-02 12:28:12 +02:00 committed by Simone Basso
commit 285290a98d
3 changed files with 56 additions and 0 deletions

View file

@ -15,6 +15,7 @@ import (
"github.com/apex/log"
"github.com/ooni/probe-cli/v3/internal/netxmocks"
utls "gitlab.com/yawning/utls.git"
)
func TestTLSHandshakerConfigurableWithError(t *testing.T) {
@ -177,3 +178,18 @@ func TestTLSHandshakerLoggerFailure(t *testing.T) {
t.Fatal("expected zero ConnectionState here")
}
}
func TestUTLSHandshakerChrome(t *testing.T) {
h := &TLSHandshakerConfigurable{
NewConn: NewConnUTLS(&utls.HelloChrome_Auto),
}
cfg := &tls.Config{ServerName: "google.com"}
conn, err := net.Dial("tcp", "google.com:443")
conn, _, err = h.Handshake(context.Background(), conn, cfg)
if err != nil {
t.Fatal("unexpected error", err)
}
if conn == nil {
t.Fatal("nil connection")
}
}