]> Cypherpunks.ru repositories - gostls13.git/commitdiff
crypto/tls: fix TestVerifyHostnameResumed
authorFilippo Valsorda <filippo@golang.org>
Fri, 17 May 2019 16:00:05 +0000 (12:00 -0400)
committerFilippo Valsorda <filippo@golang.org>
Fri, 17 May 2019 18:28:37 +0000 (18:28 +0000)
In TLS 1.3 session tickets are delivered after the handshake, and it
looks like now the Google servers wait until the first flight of data to
send them (or our timeout is too low). Cause some data to be sent so we
can avoid the guessing game.

Fixes #32090

Change-Id: I54af4acb3a89cc70c9e14a5dfe18a44c29a841a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/177877
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/crypto/tls/tls_test.go

index 0a3aeeff73ae116e022be72a85eef54068821494..df39509a6d6186cbb8df0aa9e3920b79fafbe11b 100644 (file)
@@ -372,7 +372,9 @@ func testVerifyHostnameResumed(t *testing.T, version uint16) {
                ClientSessionCache: NewLRUClientSessionCache(32),
        }
        for i := 0; i < 2; i++ {
-               c, err := Dial("tcp", "mail.google.com:https", config)
+               c, err := DialWithDialer(&net.Dialer{
+                       Timeout: 10 * time.Second,
+               }, "tcp", "mail.google.com:https", config)
                if err != nil {
                        t.Fatalf("Dial #%d: %v", i, err)
                }
@@ -389,12 +391,13 @@ func testVerifyHostnameResumed(t *testing.T, version uint16) {
                if err := c.VerifyHostname("mail.google.com"); err != nil {
                        t.Fatalf("verify mail.google.com #%d: %v", i, err)
                }
-               // Give the client a chance to read the server session tickets.
-               c.SetReadDeadline(time.Now().Add(500 * time.Millisecond))
+               // Have the server send some data so session tickets are delivered.
+               c.SetDeadline(time.Now().Add(5 * time.Second))
+               if _, err := io.WriteString(c, "HEAD / HTTP/1.0\n\n"); err != nil {
+                       t.Fatal(err)
+               }
                if _, err := c.Read(make([]byte, 1)); err != nil {
-                       if err, ok := err.(net.Error); !ok || !err.Timeout() {
-                               t.Fatal(err)
-                       }
+                       t.Fatal(err)
                }
                c.Close()
        }