Golang crypto/tls.ClientSessionCache type example

package crypto/tls

ClientSessionCache is a cache of ClientSessionState objects that can be used by a client to resume a TLS session with a given server. ClientSessionCache implementations should expect to be called concurrently from different goroutines.

Golang crypto/tls.ClientSessionCache type usage example

 conn, err := netlistener.Accept()
 sessionCache := config.ClientSessionCache
 sessionKey := config.ServerName + conn.RemoteAddr().String()

 sessionState, ok := sessionCache.Get(sessionKey)

 if ok {
 // Check if the previous session is still valid after resuming connection
 }

the code above should be residing inside a code block that is callable from goroutines.

Reference :

http://golang.org/pkg/crypto/tls/#ClientSessionCache

Advertisement