Skip to content

Commit 57a5895

Browse files
Copilotmykaul
andcommitted
Add clarification that TLS session caching works with TLS 1.2 and 1.3
TLS session resumption is not limited to TLS 1.3. It works with both: - TLS 1.2: Session IDs (RFC 5246) and Session Tickets (RFC 5077) - TLS 1.3: Session Tickets (RFC 8446) Python's ssl.SSLSession API handles both transparently, so no version checks are needed. Added documentation and code comments to clarify this. Co-authored-by: mykaul <[email protected]>
1 parent 9d68f35 commit 57a5895

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

TLS_TICKETS_DESIGN.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,17 @@ This document describes the design and implementation of TLS session ticket supp
88

99
### What are TLS Session Tickets?
1010

11-
TLS session tickets (RFC 5077 and RFC 8446 for TLS 1.3) allow clients to cache session state and reuse it for subsequent connections. This provides:
11+
TLS session tickets (RFC 5077 for TLS 1.2 and RFC 8446 for TLS 1.3) allow clients to cache session state and reuse it for subsequent connections. This provides:
1212

1313
- **Faster reconnections**: Reduced handshake latency by resuming previous sessions
1414
- **Less CPU usage**: Fewer cryptographic operations during reconnection
1515
- **Better performance**: Especially important for connection pools that frequently reconnect
1616

17+
**Note**: TLS session resumption works with both TLS 1.2 and TLS 1.3:
18+
- TLS 1.2 uses Session IDs (RFC 5246) and optionally Session Tickets (RFC 5077)
19+
- TLS 1.3 uses Session Tickets (RFC 8446) as the primary mechanism
20+
- Python's `ssl.SSLSession` API works transparently with both versions
21+
1722
### Python SSL Support
1823

1924
Python's `ssl` module provides built-in support for TLS session resumption:

cassandra/connection.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,13 @@ class TLSSessionCache:
140140
quick TLS renegotiation when reconnecting to the same server.
141141
Sessions are automatically expired after a TTL and the cache has
142142
a maximum size with LRU eviction using OrderedDict.
143+
144+
TLS session resumption works with both TLS 1.2 and TLS 1.3:
145+
- TLS 1.2: Session IDs (RFC 5246) and optionally Session Tickets (RFC 5077)
146+
- TLS 1.3: Session Tickets (RFC 8446)
147+
148+
Python's ssl.SSLSession API handles both versions transparently, so no
149+
version-specific checks are needed.
143150
"""
144151

145152
def __init__(self, max_size=100, ttl=3600):
@@ -1027,6 +1034,8 @@ def _wrap_socket_from_context(self):
10271034
opts['server_hostname'] = server_hostname
10281035

10291036
# Try to get a cached TLS session for resumption
1037+
# Note: Session resumption works with both TLS 1.2 and TLS 1.3
1038+
# Python's ssl module handles both transparently via SSLSession objects
10301039
if self.tls_session_cache:
10311040
cached_session = self.tls_session_cache.get_session(
10321041
self.endpoint.address, self.endpoint.port)

docs/security.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,10 @@ The driver automatically caches TLS sessions to enable session resumption for fa
412412
When a TLS connection is established, the session is cached and can be reused for subsequent
413413
connections to the same endpoint, reducing handshake latency and CPU usage.
414414
415+
**TLS Version Support**: Session resumption works with both TLS 1.2 and TLS 1.3. TLS 1.2 uses
416+
Session IDs and optionally Session Tickets (RFC 5077), while TLS 1.3 uses Session Tickets (RFC 8446)
417+
as the primary mechanism. Python's ``ssl.SSLSession`` API handles both versions transparently.
418+
415419
Session caching is **enabled by default** when SSL/TLS is configured and applies to the following
416420
connection classes:
417421

0 commit comments

Comments
 (0)