Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The comment on the original question is indeed correct. <a href="http://docs.oracle.com/javase/7/docs/api/javax/net/ssl/SSLEngine.html#wrap%28java.nio.ByteBuffer,%20java.nio.ByteBuffer%29%20%27SSLEngine%22" rel="nofollow noreferrer">SSLEngine</a> operates using <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/ByteBuffer.html" rel="nofollow noreferrer">ByteBuffer</a> directly. </p> <p>This means it is compatible with AIO. You start by accepting a connection. The client then connects and performs the initial write. To determine if you have enough data buffered use the <a href="http://docs.oracle.com/javase/7/docs/api/javax/net/ssl/SSLEngineResult.HandshakeStatus.html" rel="nofollow noreferrer">handshake status</a> and <a href="http://docs.oracle.com/javase/7/docs/api/javax/net/ssl/SSLEngineResult.Status.html" rel="nofollow noreferrer">status</a>. The engine will keep telling you "NEED_UNWRAP" if more data needs to be supplied from the other end. So you need to keep a queue of ByteBuffer objects. Same thing, the engine will keep telling you "NEED_WRAP" if more data needs to sent to the other end before it can continue. You keep going until you get "Finished" from the handshake status.</p> <p>I would recommend however you use something like Netty which makes this much simpler. It should be noted that Netty did have support for AIO in the alpha stages of 4. However, it was shown that AIO was slower than NIO. Hence, it was removed.</p> <p>However, not only will Netty make things simpler than trying to use NIO or AIO directly but will also make it easy to switch between the two if ever AIO is re-introduced.</p> <p>A full example of using SSL with Netty can be found <a href="https://github.com/netty/netty/tree/4.1/example/src/main/java/io/netty/example/securechat" rel="nofollow noreferrer">here</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload