I have a C++ client app that uses Boost ASIO to make SSL connections to various servers. But against 2 specific servers, the SSL connection cannot be established. It hangs in t
I figured it out. This SSL tutorial (http://h71000.www7.hp.com/doc/83final/ba554_90007/ch04s03.html) contained the key that finally got this working for me. Quote:
You can reuse the information from an already established SSL session to create a new SSL connection. Because the new SSL connection is reusing the same master secret, the SSL handshake can be performed more quickly. As a result, SSL session resumption can reduce the load of a server that is accepting many SSL connections.
So here is how I got this working with Boost ASIO:
sslSocket2.lowest_layer().connect( tcpEndpoint, ec );
SSLSocket::impl_type impl1 = sslSocket1.impl();
SSLSocket::impl_type impl2 = sslSocket2.impl();
SSL_SESSION *savedSession = SSL_get1_session( impl1->ssl );
SSL_set_session( impl2->ssl, savedSession );
SSL_connect( impl2->ssl );
That's it. At this point, no need to call sslSocket2.handshake(). Just read and write to the socket knowing the connection has been established.