Description
ClientSessionCache.Put documents that calling Put(key, nil) deletes a cache entry. In the built-in LRU cache, deleting a missing key can insert a nil-valued entry and evict a valid entry when the cache is full.
This only causes cache churn or lost resumption opportunities.
Specification or documentation
This is a Go API documentation issue rather than an external protocol violation. The relevant contract is the crypto/tls.ClientSessionCache.Put documentation for nil states.
Code references
go/src/crypto/tls/handshake_client.go:401 through go/src/crypto/tls/handshake_client.go:404 uses Put(cacheKey, nil) to delete expired sessions.
go/src/crypto/tls/handshake_client.go:421 through go/src/crypto/tls/handshake_client.go:424 uses the same deletion convention when no valid verified chain remains.
go/src/crypto/tls/common.go:395 through go/src/crypto/tls/common.go:398 documents that Put with nil should remove the cache entry.
go/src/crypto/tls/common.go:1707 through go/src/crypto/tls/common.go:1734 implements lruSessionCache.Put and lets missing-key nil puts reach the insertion or eviction path.
Test case
This should be a crypto/tls unit test for NewLRUClientSessionCache(1): insert a valid session under one key, call Put("missing", nil), and assert that the existing entry remains and the missing key is not present.
Description
ClientSessionCache.Putdocuments that callingPut(key, nil)deletes a cache entry. In the built-in LRU cache, deleting a missing key can insert a nil-valued entry and evict a valid entry when the cache is full.This only causes cache churn or lost resumption opportunities.
Specification or documentation
This is a Go API documentation issue rather than an external protocol violation. The relevant contract is the
crypto/tls.ClientSessionCache.Putdocumentation for nil states.Code references
go/src/crypto/tls/handshake_client.go:401throughgo/src/crypto/tls/handshake_client.go:404usesPut(cacheKey, nil)to delete expired sessions.go/src/crypto/tls/handshake_client.go:421throughgo/src/crypto/tls/handshake_client.go:424uses the same deletion convention when no valid verified chain remains.go/src/crypto/tls/common.go:395throughgo/src/crypto/tls/common.go:398documents thatPutwith nil should remove the cache entry.go/src/crypto/tls/common.go:1707throughgo/src/crypto/tls/common.go:1734implementslruSessionCache.Putand lets missing-key nil puts reach the insertion or eviction path.Test case
This should be a
crypto/tlsunit test forNewLRUClientSessionCache(1): insert a valid session under one key, callPut("missing", nil), and assert that the existing entry remains and the missing key is not present.