MCPcopy Create free account
hub / github.com/SenseUnit/dumbproxy / clientSessionStateFromBytes

Function clientSessionStateFromBytes

tlsutil/ccache.go:113–131  ·  view source on GitHub ↗
(data []byte)

Source from the content-addressed store, hash-verified

111}
112
113func clientSessionStateFromBytes(data []byte) (*tls.ClientSessionState, error) {
114 sce := new(sessionCacheEntry)
115 err := sce.UnmarshalBinary(data)
116 if err != nil {
117 return nil, fmt.Errorf("TLS session state unmarshaling failed: %w", err)
118 }
119 if sce.formatVersion != currentFormatVersion {
120 return nil, ErrFormatVersionMismatch
121 }
122 ss, err := tls.ParseSessionState(sce.state)
123 if err != nil {
124 return nil, fmt.Errorf("unable to parse TLS client session state: %w", err)
125 }
126 cs, err := tls.NewResumptionState(sce.ticket, ss)
127 if err != nil {
128 return nil, fmt.Errorf("unable to construct new resumption state: %w", err)
129 }
130 return cs, nil
131}
132
133var SessionCache tls.ClientSessionCache = tls.NewLRUClientSessionCache(0)
134

Callers 1

GetMethod · 0.85

Calls 2

ErrorfMethod · 0.80
UnmarshalBinaryMethod · 0.45

Tested by

no test coverage detected