Skip to content

SSL: workaround for saving big sessions from upstream servers #536

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 26, 2025

Conversation

pluknet
Copy link
Contributor

@pluknet pluknet commented Feb 21, 2025

This series implements a workaround for JDK servers, and related commits.

For JDK internals, see SSLSessionImpl.java in openjdk/jdk@94e1d7530ff

@pluknet
Copy link
Contributor Author

pluknet commented Feb 21, 2025

@arut
Copy link
Contributor

arut commented Feb 25, 2025

For simplicity, we could just increase NGX_SSL_MAX_SESSION_SIZE. The downside would be increased stack memory usage, which we can address separately by using static buffers.

@pluknet
Copy link
Contributor Author

pluknet commented Feb 25, 2025

Rewrote by moving from stack to BSS.

@@ -1024,8 +1024,6 @@ ngx_http_upstream_save_round_robin_peer_session(ngx_peer_connection_t *pc,
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
"old session: %p", old_ssl_session);

/* TODO: may block */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no direct evidence as to what exactly could block here. I'd leave this as is, but removing the comment is also fine for me.

Copy link
Contributor Author

@pluknet pluknet Feb 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's why I used "appears to be".

Although I don't insist to remove the comment,
leaving it as as, without a knowledge for what it served makes no good as well.

See 3d2fd18, where ngx_ssl_free_session was previously surrounded inside locking comments.

All such transient buffers are converted to the single storage in BSS.

In preparation to raise the limit.
Upstream SSL sessions may be of a noticeably larger size with tickets
in TLSv1.2 and older versions, or with "stateless" tickets in TLSv1.3,
if a client certificate is saved into the session.  Further, certain
stateless session resumption implemetations may store additional data.

Such one is JDK, known to also include server certificates in session
ticket data, which roughly doubles a decoded session size to slightly
beyond the previous limit.  While it's believed to be an issue on the
JDK side, this change allows to save such sessions.

Another, innocent case is using RSA certificates with 8192 key size.
@pluknet pluknet force-pushed the ssl branch 2 times, most recently from 0edb752 to bd87d14 Compare February 26, 2025 12:28
@pluknet
Copy link
Contributor Author

pluknet commented Feb 26, 2025

Addressed @arut comments, then commit logs slightly massaged.

Copy link
Contributor

@arut arut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Patches look fine. Added a comment about the commit log.

This makes it easier to understand why sessions may not be saved
in shared memory due to size.
It appears to be a relic from prototype locking removed in b0b7b5a.
@pluknet pluknet merged commit d162519 into nginx:master Feb 26, 2025
1 check passed
@pluknet pluknet deleted the ssl branch February 26, 2025 13:40
@Maryna-f5 Maryna-f5 added this to the nginx-1.27.5 milestone Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants