diff --git a/internal/handshake/qtls.go b/internal/handshake/qtls.go index 9ce5e655c..67ed90a6a 100644 --- a/internal/handshake/qtls.go +++ b/internal/handshake/qtls.go @@ -51,6 +51,10 @@ func (c *clientSessionCache) Get(sessionKey string) (*qtls.ClientSessionState, b } func (c *clientSessionCache) Put(sessionKey string, cs *qtls.ClientSessionState) { + if cs == nil { + c.ClientSessionCache.Put(sessionKey, nil) + return + } // qtls.ClientSessionState is identical to the tls.ClientSessionState. // In order to allow users of quic-go to use a tls.Config, // we need this workaround to use the ClientSessionCache. diff --git a/internal/handshake/qtls_test.go b/internal/handshake/qtls_test.go index 8a895a351..481b407dc 100644 --- a/internal/handshake/qtls_test.go +++ b/internal/handshake/qtls_test.go @@ -125,5 +125,14 @@ var _ = Describe("qtls.Config generation", func() { _, ok := qtlsConf.ClientSessionCache.Get("raboof") Expect(ok).To(BeTrue()) }) + + It("puts a nil session state", func() { + csc := NewMockClientSessionCache(mockCtrl) + tlsConf := &tls.Config{ClientSessionCache: csc} + qtlsConf := tlsConfigToQtlsConfig(tlsConf, nil, &mockExtensionHandler{}) + // put something + csc.EXPECT().Put("foobar", nil) + qtlsConf.ClientSessionCache.Put("foobar", nil) + }) }) })