Search code examples
javassljava-8niojsse

Java NIO SSL - SSLEngine Session reuse


I am implementing client and server part using Java 8 NIO and SSL. I have some doubts on creating SSLEngine.

There is one method in SSLContext

public final SSLEngine createSSLEngine(String peerHost,
                                   int peerPort)

Applications using this factory method are providing hints for an internal session reuse strategy.

While creating the SSLEngine at client side, I have to give server's ip and port. But while creating SSLEngine at server side, which IP and port I should give ?

As per RFC2246, the client has to send "Session ID" in ClientHello Message, and Server will check its "Session Cache" for its match. How would I say to server's SSLEngine to enable "Session cache" ?


Solution

  • While creating the SSLEngine at client side, I have to give server's ip and port. But while creating SSLEngine at server side, which IP and port I should give ?

    The client's.

    As per RFC2246, the client has to send "Session ID" in ClientHello Message, and Server will check its "Session Cache" for its match. How would I say to server's SSLEngine to enable "Session cache"?

    It's on by default, as long as the server-side SSLEngine knows the client IP:port.