We have a (Linux) server on which two processes are running: A and B. Currently, clients establish a connection to process A, which then passes the received socket file descriptor to handle B, allowing process B to use the existing fd / socket for unhindered communication with the client. The client and process B then handshake the TLS and continue talking about the received TLS connection.
(I leave a lot of details here, but yes, there are good reasons when process A acts as an intermediary, and not just connects directly to process B)
Now, because of the <long complicated story involving new client applications and websockets> it looks like we might have to handshake the TLS in process A, and then transfer the established TLS connection to process B.
Is it possible? The main socket file descriptor can be copied (we are already doing this), and, at least theoretically, the internal TLS state data can also be copied and used to restore the TLS connection in process B, which uses the connection efficiently.
But does OpenSSL reveal any means? I found the d2i_SSL_SESSION function, which seems to do something similar for the OpenSSL session object, but being completely new to OpenSSL, I'm not sure if that is enough. There are sessions, context, BIO and many other complex sounding terms. How much would you need to serialize and transfer to process B for this? And how will this be done in practice?
Switching should be 100% transparent for the client: it should simply perform SSL acknowledgment on this IP port, and then continue talking on the resulting socket, not knowing that one process accepts the connection and performs TLS acknowledgment, and the other processes all subsequent messages .
source share