Skip to content
This repository has been archived by the owner on Jan 31, 2024. It is now read-only.

Commit

Permalink
use a prefix for client session cache keys
Browse files Browse the repository at this point in the history
This prevents cross-protocol ticket reuse (when the same Config is used for
TCP and QUIC).
  • Loading branch information
marten-seemann committed Mar 16, 2022
1 parent 9ea6a73 commit 333d50b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions handshake_client.go
Expand Up @@ -1079,13 +1079,15 @@ func (c *Conn) getClientCertificate(cri *CertificateRequestInfo) (*Certificate,
return new(Certificate), nil
}

const clientSessionCacheKeyPrefix = "qtls-"

// clientSessionCacheKey returns a key used to cache sessionTickets that could
// be used to resume previously negotiated TLS sessions with a server.
func clientSessionCacheKey(serverAddr net.Addr, config *config) string {
if len(config.ServerName) > 0 {
return config.ServerName
return clientSessionCacheKeyPrefix + config.ServerName
}
return serverAddr.String()
return clientSessionCacheKeyPrefix + serverAddr.String()
}

// hostnameInSNI converts name into an appropriate hostname for SNI.
Expand Down

0 comments on commit 333d50b

Please sign in to comment.