Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can boost::asio::ssl::context be shared between multiple SSL streams?

Digging around the internet for a few hours I could not find an answer to my question.

My model is this: I have one shared boost::asio::ssl::context that is being used to create instances of boost::asio::ssl::stream. Then stream objects are passed along to different threads.

Is this model thread safe? Can same boost::asio::ssl::context be used in construction of different SSL stream objects that will be concurrently used?

Please, before marking this issue as a duplicate, consider reading description carefully. Thank you!

I my specific case, no objects are shared betweed threads. So anything said in Boost.Asio SSL thread safety thread safety does not affect my case. I access boost::asio::ssl::context from a single thread.

like image 713
GreenScape Avatar asked Sep 27 '22 07:09

GreenScape


1 Answers

Because SSL contexts needs to be shared among SSL sessions (otherwise, how would session resumption work) the SSL context class is fully, internally thread safe. You can use an SSL context in multiple SSL connections and from multiple threads however you want.

like image 107
David Schwartz Avatar answered Sep 30 '22 05:09

David Schwartz