Search code examples
c++boostssltcpboost-asio

boost::asio handshake through http proxy?


Quite new to boost and asio, need help:

  1. connect to proxy asio::ip::tcp::socket socket_;

  2. send CONNECT host: ssl server to the proxy receive response 200

  3. asio::ssl::context ctx(io_service, asio::ssl::context::sslv23); sslsocket_(socket_,context)
  4. try handshake sslsocket_.async_handshake(asio::ssl::stream_base::client, boost::bind(&client::handle_handshake, this, asio::placeholders::error));

  5. and get asio.ssl error Wireshark: host sends FIN after 1st message of handshake

Direct async connection to ssl server works fine, same through Proxifier


Solution

  • Forgot to mention that was running the application in VMplayer with NAT network; bridged removed the problem with initial handshake but sometimes after reconnect saw the same message; using the method in Sam's link got to "unexpected record" during handshake - google said on this error about renegotiations but that was not the case; digging into sources of OpenSSL: the new connection used the same BIO for reading and recevied application data from previous connection Don't know how to reset the SSL structure with asio, so made dynamic socket allocation with new|delete