fix crash when the server disabled session resumption

This commit is contained in:
Marten Seemann
2019-07-16 18:45:51 +07:00
parent 879467b3c5
commit ce0b1f2736
3 changed files with 41 additions and 3 deletions

View File

@@ -84,4 +84,42 @@ var _ = Describe("TLS session resumption", func() {
Expect(err).ToNot(HaveOccurred())
Expect(serverSess.ConnectionState().DidResume).To(BeTrue())
})
It("doesn't use session resumption, if the config disables it", func() {
sConf := getTLSConfig()
sConf.SessionTicketsDisabled = true
server, err := quic.ListenAddr("localhost:0", sConf, nil)
Expect(err).ToNot(HaveOccurred())
defer server.Close()
gets := make(chan string, 100)
puts := make(chan string, 100)
cache := newClientSessionCache(gets, puts)
tlsConf := getTLSClientConfig()
tlsConf.ClientSessionCache = cache
sess, err := quic.DialAddr(
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
tlsConf,
nil,
)
Expect(err).ToNot(HaveOccurred())
Consistently(puts).ShouldNot(Receive())
Expect(sess.ConnectionState().DidResume).To(BeFalse())
serverSess, err := server.Accept(context.Background())
Expect(err).ToNot(HaveOccurred())
Expect(serverSess.ConnectionState().DidResume).To(BeFalse())
sess, err = quic.DialAddr(
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
tlsConf,
nil,
)
Expect(err).ToNot(HaveOccurred())
Expect(sess.ConnectionState().DidResume).To(BeFalse())
serverSess, err = server.Accept(context.Background())
Expect(err).ToNot(HaveOccurred())
Expect(serverSess.ConnectionState().DidResume).To(BeFalse())
})
})