Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. boost::asio::io_service io;
  2. boost::asio::ssl::context ctx(boost::asio::ssl::context::sslv23_client);
  3. boost::asio::ssl::stream<boost::asio::ip::tcp::socket> backend(io, ctx);
  4.  
  5. // need some object that will store the cache
  6. std::map<std::string, SSL_SESSION*> ssl_cache;
  7.  
  8. // add session to the cache after a successful connection
  9. SSL_SESSION *session = SSL_get1_session(backend.native_handle());
  10. ssl_cache[host] = session;
  11.  
  12. // before a new connection to the 'host', check the cache
  13. auto cached_session = ssl_cache.find(host);
  14. if (cached_session != ssl_cache.end())
  15. {
  16. SSL_SESSION *session = cached_session->second;
  17. SSL_set_session(backend.native_handle(), session);
  18. }
  19.  
  20. // after a connection can check if ssl-session was reused
  21. if (SSL_session_reused(backend.native_handle()))
  22. {
  23. // reused
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement