Skip to content

Support session cache for client and server when using native SSLEngi…#10331

Merged
normanmaurer merged 1 commit into4.1from
session_reuse
Jul 14, 2020
Merged

Support session cache for client and server when using native SSLEngi…#10331
normanmaurer merged 1 commit into4.1from
session_reuse

Conversation

@normanmaurer
Copy link
Copy Markdown
Member

…ne implementation

Motivation:

At the moment we don't support session caching for client side when using native SSLEngine implementation and our implementation of SSLSessionContext is incomplete.

Modification:

  • Consume netty-tcnative changes to be able to cache session in an external cache
  • Add and adjust unit tests to test session caching
  • Add an in memory session cache that is hooked into native SSLEngine

Result:

Support session caching on the client and server side

@normanmaurer
Copy link
Copy Markdown
Member Author

Depends on netty/netty-tcnative#548

@normanmaurer normanmaurer requested review from Scottmitch, danbim and idelpivnitskiy and removed request for danbim May 29, 2020 15:48
@normanmaurer normanmaurer requested review from carl-mastrangelo and removed request for idelpivnitskiy June 2, 2020 14:34
Copy link
Copy Markdown
Member

@idelpivnitskiy idelpivnitskiy left a comment

Choose a reason for hiding this comment

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

Looks promising, great work!
Will do a second review pass later

@normanmaurer normanmaurer marked this pull request as ready for review June 5, 2020 07:03
@normanmaurer
Copy link
Copy Markdown
Member Author

@idelpivnitskiy PTAL again

@normanmaurer normanmaurer force-pushed the session_reuse branch 2 times, most recently from d92883c to c57927a Compare June 25, 2020 20:21
@normanmaurer
Copy link
Copy Markdown
Member Author

@netty-bot test this please

Copy link
Copy Markdown
Member

@idelpivnitskiy idelpivnitskiy left a comment

Choose a reason for hiding this comment

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

LGTM, awesome work!
A few minor comments and questions:

context.setSessionCacheSize((int) Math.min(sessionCacheSize, Integer.MAX_VALUE));
}
if (sessionTimeout > 0) {
context.setSessionTimeout((int) Math.min(sessionTimeout, Integer.MAX_VALUE));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we throw if the requested sessionCacheSize/sessionTimeout is higher than Integer.MAX_VALUE? Or at least log it? Silent override may be confusing.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this is the same code we use for the JDK implementation. Let me think about it and make a follow up if needed to keep it consistent.

try {
doHandshakeVerifyReusedAndClose("a.netty.io", 9999, false);
// As we have a cache size of 1 we should never have more then one session in the cache
doHandshakeVerifyReusedAndClose("b.netty.io", 9999, false);
Copy link
Copy Markdown
Member

@idelpivnitskiy idelpivnitskiy Jun 26, 2020

Choose a reason for hiding this comment

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

Can we verify that a single session available in cache is reused for a.netty.io?

// the handshake is done.
// See https://www.openssl.org/docs/man1.1.1/man3/SSL_CTX_sess_set_get_cb.html
if (!SslUtils.PROTOCOL_TLS_V1_3.equals(engine.getSession().getProtocol())) {
assertEquals(isReused, engine.isSessionReused());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I probably miss it somewhere, but how do you know if the session was reused via session ticket, not session id for TLSv1.2?

@normanmaurer
Copy link
Copy Markdown
Member Author

@netty-bot test this please

@normanmaurer
Copy link
Copy Markdown
Member Author

Factored out some bug fix in another PR that is not really related to this one #10388

@normanmaurer
Copy link
Copy Markdown
Member Author

@netty-bot test this please

@normanmaurer
Copy link
Copy Markdown
Member Author

@netty-bot test this please

@normanmaurer
Copy link
Copy Markdown
Member Author

Once this build passes I will merge this one in....

…ne implementation

Motivation:

At the moment we don't support session caching for client side when using native SSLEngine implementation and our implementation of SSLSessionContext is incomplete.

Modification:

- Consume netty-tcnative changes to be able to cache session in an external cache
- Add and adjust unit tests to test session caching
- Add an in memory session cache that is hooked into native SSLEngine

Result:

Support session caching on the client and server side
@normanmaurer normanmaurer merged commit 825916c into 4.1 Jul 14, 2020
@normanmaurer normanmaurer deleted the session_reuse branch July 14, 2020 10:22
@normanmaurer normanmaurer added this to the 4.1.52.Final milestone Jul 14, 2020
normanmaurer added a commit that referenced this pull request Jul 14, 2020
…ne implementation (#10331)

Motivation:

At the moment we don't support session caching for client side when using native SSLEngine implementation and our implementation of SSLSessionContext is incomplete.

Modification:

- Consume netty-tcnative changes to be able to cache session in an external cache
- Add and adjust unit tests to test session caching
- Add an in memory session cache that is hooked into native SSLEngine

Result:

Support session caching on the client and server side
Kvicii pushed a commit to Kvicii/netty that referenced this pull request Jul 15, 2020
* '4.1' of github.com:netty/netty:
  Support session cache for client and server when using native SSLEngine implementation (netty#10331)
  Simple fix typo (netty#10403)
  Eliminate a redundant method call in HpackDynamicTable.add(...) (netty#10399)
  jdk.tls.client.enableSessionTicketExtension must be respected by OPENSSL and OPENSSL_REFCNT SslProviders (netty#10401)
Kvicii pushed a commit to Kvicii/netty that referenced this pull request Jul 20, 2020
* '4.1-read' of github.com:Kvicii/netty: (43 commits)
  Make the TLSv1.3 check more robust and not depend on the Java version… (netty#10409)
  Reduce the scope of synchronized block in PoolArena (netty#10410)
  Add IndexOutOfBoundsException error message (netty#10405)
  Add default handling for switch statement (netty#10408)
  Review PooledByteBufAllocator in respect of jemalloc 4.x changes and update allocate algorithm.(netty#10267)
  Support session cache for client and server when using native SSLEngine implementation (netty#10331)
  Simple fix typo (netty#10403)
  Eliminate a redundant method call in HpackDynamicTable.add(...) (netty#10399)
  jdk.tls.client.enableSessionTicketExtension must be respected by OPENSSL and OPENSSL_REFCNT SslProviders (netty#10401)
  重新编译4.1分支
  [maven-release-plugin] prepare for next development iteration
  [maven-release-plugin] prepare release netty-4.1.51.Final
  Correctly return NEED_WRAP if we produced some data even if we could not consume any during SSLEngine.wrap(...) (netty#10396)
  Modify OpenSSL native library loading to accommodate GraalVM (netty#10395)
  Update to netty-tcnative 2.0.31.Final and make SslErrorTest more robust (netty#10392)
  Add option to HttpObjectDecoder to allow duplicate Content-Lengths (netty#10349)
  Add detailed error message corresponding to the IndexOutOfBoundsException while calling getEntry(...) (netty#10386)
  Do not report ReferenceCountedOpenSslClientContext$ExtendedTrustManagerVerifyCallback.verify as blocking call (netty#10387)
  Add unit test for HpackDynamicTable. (netty#10389)
  netty用于测试的内嵌Channel | ChannelInboundHandler主要方法
  ...
ihanyong pushed a commit to ihanyong/netty that referenced this pull request Jul 31, 2020
…ne implementation (netty#10331)

Motivation:

At the moment we don't support session caching for client side when using native SSLEngine implementation and our implementation of SSLSessionContext is incomplete.

Modification:

- Consume netty-tcnative changes to be able to cache session in an external cache
- Add and adjust unit tests to test session caching
- Add an in memory session cache that is hooked into native SSLEngine

Result:

Support session caching on the client and server side
normanmaurer added a commit that referenced this pull request Sep 2, 2020
… SSLEngine implementation (#10331)"

Motivation:

This reverts commit 825916c as it turns out it introduced a big performance regression.

Modifications:

Revert 825916c

Result:

Performance of TLS is back to normal
normanmaurer added a commit that referenced this pull request Sep 3, 2020
… SSLEngine implementation (#10331)" (#10528)

Motivation:

This reverts commit 825916c as it turns out it introduced a big performance regression.

Modifications:

Revert 825916c

Result:

Performance of TLS is back to normal
normanmaurer added a commit that referenced this pull request Sep 3, 2020
… SSLEngine implementation (#10331)"

Motivation:

This reverts commit 7bf1ffb as it turns out it introduced a big performance regression.

Modifications:

Revert 7bf1ffb

Result:

Performance of TLS is back to normal
@normanmaurer normanmaurer removed this from the 4.1.52.Final milestone Sep 8, 2020
normanmaurer added a commit that referenced this pull request Oct 2, 2020
…g native SSLEngine implementation (#10331)" (#10528)"

This reverts commit 5157d3b.
normanmaurer added a commit that referenced this pull request Oct 14, 2020
…g native SSLEngine implementation (#10331)" (#10528)"

This reverts commit 5157d3b.
normanmaurer added a commit that referenced this pull request Feb 2, 2021
…g native SSLEngine implementation (#10331)" (#10528)"

This reverts commit 5157d3b.
normanmaurer added a commit that referenced this pull request Feb 11, 2021
…g native SSLEngine implementation (#10331)" (#10528)"

This reverts commit 5157d3b.
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