Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- boost::asio::io_service io;
- boost::asio::ssl::context ctx(boost::asio::ssl::context::sslv23_client);
- boost::asio::ssl::stream<boost::asio::ip::tcp::socket> backend(io, ctx);
- // need some object that will store the cache
- std::map<std::string, SSL_SESSION*> ssl_cache;
- // add session to the cache after a successful connection
- SSL_SESSION *session = SSL_get1_session(backend.native_handle());
- ssl_cache[host] = session;
- // before a new connection to the 'host', check the cache
- auto cached_session = ssl_cache.find(host);
- if (cached_session != ssl_cache.end())
- {
- SSL_SESSION *session = cached_session->second;
- SSL_set_session(backend.native_handle(), session);
- }
- // after a connection can check if ssl-session was reused
- if (SSL_session_reused(backend.native_handle()))
- {
- // reused
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement