Skip to content

Commit

Permalink
Merge pull request #4520 from alainjobart/tls
Browse files Browse the repository at this point in the history
tlstest_test: Go 1.12 / TLS 1.3 fix
  • Loading branch information
alainjobart authored Jan 14, 2019
2 parents e9e9163 + bf5e4b1 commit b06cf39
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions go/vt/tlstest/tlstest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,21 @@ func TestClientServer(t *testing.T) {
serverConn.Close()
}()

if _, err = tls.Dial("tcp", addr, badClientConfig); err == nil {
t.Fatalf("Dial was expected to fail")
// When using TLS 1.2, the Dial will fail.
// With TLS 1.3, the Dial will succeed and the first Read will fail.
clientConn, err := tls.Dial("tcp", addr, badClientConfig)
if err != nil {
if !strings.Contains(err.Error(), "bad certificate") {
t.Errorf("Wrong error returned: %v", err)
}
return
}
data := make([]byte, 1)
_, err = clientConn.Read(data)
if err == nil {
t.Fatalf("Dial or first Read was expected to fail")
}
if !strings.Contains(err.Error(), "bad certificate") {
t.Errorf("Wrong error returned: %v", err)
}
t.Logf("Dial returned: %v", err)
}

0 comments on commit b06cf39

Please sign in to comment.