Friday 2 June 2017

Node.JS regenerate SSL socket without closing raw socket

I have to write a Node.js application that must...

1) Make a socket connection to a server, send and receive an initial message exchange.

2) Upgrade the socket to SSL, send a login message and receive a status message over SSL.

3) Tear down the SSL connection without closing the raw socket.

4) exchange a message over the raw socket again.

5) Upgrade the socket again to SSL and continue using SSL for the duration of the processing.

I can't seem to figure out how to tear down the SSL connection leaving the raw socket open and usable for non-SSL traffic then upgrade it again to SSL.

The reason for having to do this is that the server I am connecting to uses the initial non-SSL exchange so the client and server can decide what capabilities they both have and if they can switch to SSL or not. After the server authenticates my credentials over SSL it then spawns off a new process to handle the rest of the session. To do that is tears down the SSL layer, passes the raw open socket to the other process, the other process then handshakes with the client that it is running then the connection is again upgraded to SSL. The SSL context can't seem to be passed between processes but the raw socket can.



via Pete Brower

No comments:

Post a Comment