forked from quic-go/quic-go
fix putting of a nil ClientSessionState into a qtls.ClientSessionCache
This commit is contained in:
@@ -51,6 +51,10 @@ func (c *clientSessionCache) Get(sessionKey string) (*qtls.ClientSessionState, b
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *clientSessionCache) Put(sessionKey string, cs *qtls.ClientSessionState) {
|
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.
|
// qtls.ClientSessionState is identical to the tls.ClientSessionState.
|
||||||
// In order to allow users of quic-go to use a tls.Config,
|
// In order to allow users of quic-go to use a tls.Config,
|
||||||
// we need this workaround to use the ClientSessionCache.
|
// we need this workaround to use the ClientSessionCache.
|
||||||
|
|||||||
@@ -125,5 +125,14 @@ var _ = Describe("qtls.Config generation", func() {
|
|||||||
_, ok := qtlsConf.ClientSessionCache.Get("raboof")
|
_, ok := qtlsConf.ClientSessionCache.Get("raboof")
|
||||||
Expect(ok).To(BeTrue())
|
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)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user