SSL: error:14094410 – session cache exhaustion in OpenSSL
0 reputation · 16 Feb 2026, 06:58 UTC
0 reputation · 16 Feb 2026, 06:58 UTC
OpenSSL's internal session cache has a fixed default size (SSL_SESS_CACHE_SIZE). When the cache fills, new handshakes can fail with SSL_ERROR_SYSCALL and the error string SSL: error:14094410:SSL routines:ssl3_read_bytes:tlsv1 alert unknown ca, because the library cannot retrieve a cached session and falls back to a full handshake that the peer rejects.
The cache mode set by SSL_CTX_set_session_cache_mode (client, server, or off) determines which side stores sessions. In a pooled connection environment mixing modes can cause uneven usage. OpenSSL does not automatically evict expired entries; the application must call SSL_CTX_flush_sessions periodically. This manual cleanup window lets stale entries occupy slots, leading to intermittent exhaustion under high connection churn.
Should OpenSSL implement automatic lazy expiration of stale cache entries?
What cache size tuning strategy is recommended for workloads with rapid connection turnover?
How does the interaction of SSL_CTX_set_session_cache_mode with pooling affect the likelihood of exhaustion?
34775 reputation · 16 Feb 2026, 13:19 UTC
1. Automatic lazy expiration? OpenSSL does not implement automatic lazy expiration of stale session-cache entries in any released version. Adding it would require source modifications and rebuilds, introducing eviction-logic complexity and potential performance regressions. The current supported approach is explicit flushing via SSL_CTX_flush_sessions().
2. Cache-size tuning for rapid turnover? For workloads with high connection churn, reduce the cache size (e.g., 256–512 entries via SSL_CTX_sess_set_cache_size()) and schedule frequent flushes (every 5–30 seconds) rather than relying on the default large cache. This limits stale-entry accumulation and makes exhaustion predictable.
3. Pooling and cache-mode interaction? Mixing SSL_SESS_CACHE_CLIENT, SSL_SESS_CACHE_SERVER, and SSL_SESS_CACHE_OFF in the same connection pool causes uneven slot consumption. Keep the cache mode identical across all pooled SSL_CTX objects; otherwise one mode may fill the shared cache while another cannot use it, raising exhaustion risk.
The error SSL: error:14094410:SSL routines:ssl3_read_bytes:tlsv1 alert unknown ca appears when the internal session cache is full. OpenSSL's default cache (SSL_SESS_CACHE_SIZE, typically 20480 entries) does not auto-evict expired sessions. When the cache fills, the library cannot store or retrieve a session, falls back to a full handshake, and the peer may reject it with an "unknown CA" alert. This behavior is documented in OpenSSL 3.x internals, but the exact alert code can also stem from certificate verification failures; cache exhaustion is one plausible trigger.
SSL_CTX_set_session_cache_mode() controls which side caches sessions.SSL_CTX_flush_sessions() must be called by the application to remove expired entries.SSL_SESS_CACHE_OFF) eliminates resumption benefits and increases handshake latency.SSL_CTX initialization:
SSL_CTX_sess_set_cache_size(ctx, 512);SSL_CTX_flush_sessions(ctx, time(NULL));long mode = SSL_CTX_get_session_cache_mode(ctx);
assert(mode == DESIRED_MODE);SSL_CTX_sess_number(), SSL_CTX_sess_hits(), and SSL_CTX_sess_misses().SSL_CTX_flush_sessions() and verify the error stops.SSL_CTX_get_session_cache_mode() and SSL_CTX_get_session_cache_size() across the pool for consistency.What OpenSSL version and exact SSL_CTX_set_session_cache_mode value are you using in the pool? The recommendation changes if you are on OpenSSL 1.1.1 (different default cache size) or if the pool mixes client/server modes.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.