i found this article :
-
While Java's secure socket API (in package javax.net.ssl) parallels that of regular sockets, there are no classes that correspond to the new java.nio.channels.SocketChannel and java.nio.channels.ServerSocketChannel classes in the non-blocking I/O package. This is unfortunate because their omission prevents Java application developers from using new features such as non-blocking connection (SSL handshaking on connection can take a significant amount of time), asynchronous channel closure, and channel interrupt.
The word from Sun is that support will appear in a later release. Until then, you'll have to glue non-blocking I/O channels and secure sockets together by hand.
The message suggests trying to glue non-blocking I/O channels and secure sockets together by hand.
How?
You can't alter the socket in a SocketChannel to stick in an SSL Socket. Having one thread per open SSL connection is not really a tenable solution if you expect most clients to connect via SSL because of a desire to make a secure application on your server.
Anybody know what they mean by "later release"?
You can't. It just seems that you can. Syntactically, you can glue things together by hand like this:
SocketChannel socketChannel = SocketChannel.open(...);
SSLSocket sslSocket = (SSLSocket)SSLSocketFactory.createSocket(socketChannel.socket(), ...);
or like this:
SSLSocket sslSocket = (SSLSocket)SSLSocketFactory.createSocket(host,port);
ReadableByteChannel rbc = Channels.newChannel(sslSocket.getInputStream());
WritableByteChannel wbc = Channels.newChannel(sslSocket.getOutputStream());
However this is of no use: it won't execute, because the SSLSocket will object, or react badly, to being put into non-blocking mode. We have to wait for Sun.
EJP
By the way, great information EJB! Is this still true? It appears that non-blocking with the current SSL hierarchy is a no no. Is that right?
I tried looking throught he stuff, and I see the SSL handshaking stuff in the impl classes, and I'm guess that code relies on not moving forward until something's been written.
Is there any offical blurb from Sun on this?
Thanks!
-Thomas