Skip to content

Commit 20e4540

Browse files
committed
crypto/tls: remove TestVerifyHostnameResumed
Session resumption is not a reliable TLS behavior: the server can decide to reject a session ticket for a number of reasons, or no reason at all. This makes this non-hermetic test extremely brittle. It's currently broken on the builders for both TLS 1.2 and TLS 1.3, and I could reproduce the issue for TLS 1.3 only. As I was debugging it, it started passing entirely on my machine. In practice, it doesn't get us any coverage as resumption is already tested with the recorded exchange tests, and TestVerifyHostname still provides a smoke test checking that we can in fact talk TLS. Fixes #32978 Change-Id: I63505e22ff7704f25ad700d46e4ff14850ba5d3c Reviewed-on: https://go-review.googlesource.com/c/go/+/186239 Run-TryBot: Filippo Valsorda <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]>
1 parent b9edee3 commit 20e4540

File tree

1 file changed

+0
-44
lines changed

1 file changed

+0
-44
lines changed

src/crypto/tls/tls_test.go

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -359,50 +359,6 @@ func TestVerifyHostname(t *testing.T) {
359359
}
360360
}
361361

362-
func TestVerifyHostnameResumed(t *testing.T) {
363-
t.Run("TLSv12", func(t *testing.T) { testVerifyHostnameResumed(t, VersionTLS12) })
364-
t.Run("TLSv13", func(t *testing.T) { testVerifyHostnameResumed(t, VersionTLS13) })
365-
}
366-
367-
func testVerifyHostnameResumed(t *testing.T, version uint16) {
368-
testenv.MustHaveExternalNetwork(t)
369-
370-
config := &Config{
371-
MaxVersion: version,
372-
ClientSessionCache: NewLRUClientSessionCache(32),
373-
}
374-
for i := 0; i < 2; i++ {
375-
c, err := DialWithDialer(&net.Dialer{
376-
Timeout: 10 * time.Second,
377-
}, "tcp", "mail.google.com:https", config)
378-
if err != nil {
379-
t.Fatalf("Dial #%d: %v", i, err)
380-
}
381-
cs := c.ConnectionState()
382-
if i > 0 && !cs.DidResume {
383-
t.Fatalf("Subsequent connection unexpectedly didn't resume")
384-
}
385-
if cs.Version != version {
386-
t.Fatalf("Unexpectedly negotiated version %x", cs.Version)
387-
}
388-
if cs.VerifiedChains == nil {
389-
t.Fatalf("Dial #%d: cs.VerifiedChains == nil", i)
390-
}
391-
if err := c.VerifyHostname("mail.google.com"); err != nil {
392-
t.Fatalf("verify mail.google.com #%d: %v", i, err)
393-
}
394-
// Have the server send some data so session tickets are delivered.
395-
c.SetDeadline(time.Now().Add(5 * time.Second))
396-
if _, err := io.WriteString(c, "HEAD / HTTP/1.0\n\n"); err != nil {
397-
t.Fatal(err)
398-
}
399-
if _, err := c.Read(make([]byte, 1)); err != nil {
400-
t.Fatal(err)
401-
}
402-
c.Close()
403-
}
404-
}
405-
406362
func TestConnCloseBreakingWrite(t *testing.T) {
407363
ln := newLocalListener(t)
408364
defer ln.Close()

0 commit comments

Comments
 (0)