ignore QUICConn.SendSessionTicket error if session tickets are disabled (#4030)

This commit is contained in:
Marten Seemann 2023-08-16 09:53:41 +07:00 committed by GitHub
parent 70f3f44a09
commit 1d848392bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 62 additions and 8 deletions

View file

@ -56,7 +56,7 @@ var _ = Describe("TLS session resumption", func() {
context.Background(),
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
tlsConf,
nil,
getQuicConfig(nil),
)
Expect(err).ToNot(HaveOccurred())
var sessionKey string
@ -71,7 +71,7 @@ var _ = Describe("TLS session resumption", func() {
context.Background(),
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
tlsConf,
nil,
getQuicConfig(nil),
)
Expect(err).ToNot(HaveOccurred())
Expect(gets).To(Receive(Equal(sessionKey)))
@ -85,7 +85,7 @@ var _ = Describe("TLS session resumption", func() {
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)
server, err := quic.ListenAddr("localhost:0", sConf, getQuicConfig(nil))
Expect(err).ToNot(HaveOccurred())
defer server.Close()
@ -98,7 +98,7 @@ var _ = Describe("TLS session resumption", func() {
context.Background(),
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
tlsConf,
nil,
getQuicConfig(nil),
)
Expect(err).ToNot(HaveOccurred())
Consistently(puts).ShouldNot(Receive())
@ -114,7 +114,55 @@ var _ = Describe("TLS session resumption", func() {
context.Background(),
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
tlsConf,
nil,
getQuicConfig(nil),
)
Expect(err).ToNot(HaveOccurred())
Expect(conn.ConnectionState().TLS.DidResume).To(BeFalse())
serverConn, err = server.Accept(context.Background())
Expect(err).ToNot(HaveOccurred())
Expect(serverConn.ConnectionState().TLS.DidResume).To(BeFalse())
})
It("doesn't use session resumption, if the config returned by GetConfigForClient disables it", func() {
sConf := &tls.Config{
GetConfigForClient: func(*tls.ClientHelloInfo) (*tls.Config, error) {
conf := getTLSConfig()
conf.SessionTicketsDisabled = true
return conf, nil
},
}
server, err := quic.ListenAddr("localhost:0", sConf, getQuicConfig(nil))
Expect(err).ToNot(HaveOccurred())
defer server.Close()
gets := make(chan string, 100)
puts := make(chan string, 100)
cache := newClientSessionCache(tls.NewLRUClientSessionCache(10), gets, puts)
tlsConf := getTLSClientConfig()
tlsConf.ClientSessionCache = cache
conn, err := quic.DialAddr(
context.Background(),
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
tlsConf,
getQuicConfig(nil),
)
Expect(err).ToNot(HaveOccurred())
Consistently(puts).ShouldNot(Receive())
Expect(conn.ConnectionState().TLS.DidResume).To(BeFalse())
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()
serverConn, err := server.Accept(ctx)
Expect(err).ToNot(HaveOccurred())
Expect(serverConn.ConnectionState().TLS.DidResume).To(BeFalse())
conn, err = quic.DialAddr(
context.Background(),
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
tlsConf,
getQuicConfig(nil),
)
Expect(err).ToNot(HaveOccurred())
Expect(conn.ConnectionState().TLS.DidResume).To(BeFalse())