harmeetsingh-work/naga

Improve NIOSocketSSL class.

Closed this issue · 3 comments

Sometimes you need to use plain socket connection and it's very easy with naga.
But sometimes you need to secure existing plain connection, for example, when 
user makes some actions that needs to be secure.

I try the following:

secureSocket = new SSLSocketChannelResponder(plainSocket, 
sslContext.createSSLEngine(), true);

but it doesn't work.

Original issue reported on code.google.com by abuhar...@gmail.com on 12 Mar 2011 at 7:19

The correct way of using it is to use it like the normal NIOSocket classes, 
i.e. create a NIOService then call 
nioService.openSSLSocket(sslContext.createSSLEngine(), url, port). I see how 
that was a bit confusing as the visibility of those classes were incorrectly 
set to public.
I've fixed the visibility of the classes in the latest update.

Original comment by christof...@gmail.com on 12 Mar 2011 at 8:11

  • Changed state: Fixed
Ok, but how to open plain socket connection use it and then make it secure?

Original comment by abuhar...@gmail.com on 12 Mar 2011 at 8:14

Without naga I can do:

------------------------------------------------
private Socket socket;
...
Socket plain = socket;
// Secure the plain connection
socket = context.getSocketFactory().createSocket(plain,
plain.getInetAddress().getHostName(), plain.getPort(), true);
// Initialize the reader and writer with the new secured version
initReaderAndWriter();
// Proceed to do the handshake
 ((SSLSocket) socket).startHandshake();
...
------------------------------------------------

How I can do it with naga?

Original comment by abuhar...@gmail.com on 15 Mar 2011 at 9:04