OpenSSL 3.0 client behind nginx reverse proxy: stale OCSP responses after responder URL change
0 reputation · 10 Mar 2025, 00:51 UTC
0 reputation · 10 Mar 2025, 00:51 UTC
We run an OpenSSL 3.0-based client application that validates certificates from an internal nginx reverse proxy (also built on OpenSSL 3.0) with OCSP stapling enabled. The OCSP responder URL in our CA-issued certificates recently changed, and we want to understand how caching on each side affects the freshness of the status information the client ultimately sees.
The goal is to guarantee that the client never accepts an OCSP response older than a defined freshness window after the responder migration, without disabling OCSP entirely. Our uncertainty is where staleness can persist: the client-side session/OCSP cache controlled by SSL_CTX_set_cache_mode() and SSL_CTX_set_timeout(), or the stapled response nginx caches and serves to every connecting client. We currently use SSL_CACHE_DEFAULT and a long session timeout, and it is unclear whether session resumption can bypass fresh status checks altogether.
SSL_CACHE_OFF and paying a full handshake every connection?32275 reputation · 10 Mar 2025, 02:05 UTC
SSL_CTX_set_timeout() to a short value and by using a cache mode that respects that timeout. After changing the responder URL you can purge the client cache with SSL_CTX_flush_sessions() without disabling caching.thisUpdate and nextUpdate fields fall within the desired window; otherwise it must either force a full handshake or perform a direct OCSP query.The stapling cache lives on the server side. Nginx keeps a per‑upstream cache of stapled responses and serves the same response to every client that performs a session‑resume, regardless of whether the underlying responder URL has changed. The client’s own cache only records the stapled response once; it does not trigger a new stapling request on resume.
ssl_stapling_response_cache and ssl_stapling_cache_size to a small value (e.g., 5 s). This forces nginx to fetch a fresh response from the new responder more frequently.SSL_CTX *ctx = SSL_CTX_new(TLS_client_method());
SSL_CTX_set_cache_mode(ctx, SSL_CACHE_CLIENT); /* use client‑side cache */
SSL_CTX_set_timeout(ctx, 60); /* 60‑second freshness window */
SSL_CTX_flush_sessions(ctx, 0); /* purge all cached sessions */
This forces the next connection to perform a full handshake and fetch a fresh stapled response.thisUpdate and nextUpdate fields (via SSL_get0_ocsp_response()) and compare them to the current time. If the response is outside your window, reject the handshake or trigger a direct OCSP query.To fine‑tune the policy, we need to know the current ssl_stapling_cache_size and ssl_stapling_response_cache values in nginx. If these are set to a large value, stale stapled responses may linger longer than desired.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.