Boost logo

Boost Users :

From: Martijn Otto (boost_at_[hidden])
Date: 2019-09-29 17:11:00


On Sat, 2019-09-28 at 07:31 +0500, Dmitrij V via Boost-users wrote:
> Martijn Otto wrote:
> > I could make a pull-request to implement these changes, if so
> > desired.
>
> +1, changes + documentation on its, please :)
>
> > Does this have any change of getting merged?
>
> Oh, that is not in my authority, but please, send the PR into
> https://github.com/chriskohlhoff/asio too
>
> --
> regards
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> https://lists.boost.org/mailman/listinfo.cgi/boost-users

After reading through the source code some more, it seems that no
changes are actually necessary, since my initial code was already safe.
I'll explain why.

The ssl::stream constructor, which does get a reference to the
ssl::context and extracts the underlying SSL_CTX but does not keep this
in a member. Instead, it forwards it to its core_ member, which is an
instance of detail::stream_core. detail::stream_core then forwards it
to its engine_ member, which is an instance of detail::engine.

detail::engine then uses it to call SSL_new. The documentation for
SSL_new does not explicitly mention it, but looking through the code I
can see it call SSL_CTX_up_ref(), which increases the reference count
on the underlying SSL_CTX, which means that even if the ssl_context
calls SSL_CTX_free(), the context will remain valid if there is an
ssl::stream using it.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net