You must make sure not to write a message while the handshake is in progress unless you are renegotiating. You will be notified by the {@link Future} which isreturned by the {@link #handshakeFuture()} method when the handshakeprocess succeeds or fails.
Beside using the handshake {@link ChannelFuture} to get notified about the completation of the handshake it'salso possible to detect it by implement the {@link ChannelHandler#userEventTriggered(ChannelHandlerContext,Object)}method and check for a {@link SslHandshakeCompletionEvent}.
The handshake will be automaticly issued for you once the {@link Channel} is active and{@link SSLEngine#getUseClientMode()} returns {@code true}. So no need to bother with it by your self.
To close the SSL session, the {@link #close()} method should becalled to send the {@code close_notify} message to the remote peer. Oneexception is when you close the {@link Channel} - {@link SslHandler}intercepts the close request and send the {@code close_notify} messagebefore the channel closure automatically. Once the SSL session is closed, it is not reusable, and consequently you should create a new {@link SslHandler} with a new {@link SSLEngine} as explained in thefollowing section.
To restart the SSL session, you must remove the existing closed {@link SslHandler} from the {@link ChannelPipeline}, insert a new {@link SslHandler} with a new {@link SSLEngine} into the pipeline,and start the handshake process as described in the first section.
StartTLS is the communication pattern that secures the wire in the middle of the plaintext connection. Please note that it is different from SSL · TLS, that secures the wire from the beginning of the connection. Typically, StartTLS is composed of three steps:
The client-side implementation is much simpler.
Because of a known issue with the current implementation of the SslEngine that comes with Java it may be possible that you see blocked IO-Threads while a full GC is done.
So if you are affected you can workaround this problem by adjust the cache settings like shown below:
SslContext context = ...; context.getServerSessionContext().setSessionCacheSize(someSaneSize); context.getServerSessionContext().setSessionTime(someSameTimeout);
What values to use here depends on the nature of your application and should be set based on monitoring and debugging of it. For more details see #832 in our issue tracker.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|