> I am wrapping an ssl socket using c++ and use a third party library
> steam implementation. the library I use requires an implementation of a
> copy constructor. I managed to dup and initialize a simple BIO and then
> free it as required, but when it comes to SSL struct, thing don't seem
> to work the same way.
> BIO code:
> used in copy constructor:
[snip]
> I am looking for a way to duplicate the SSL struct with all of it's
> components in order to keep using it without a new handshake.
> destructor is pretty straight forward, but copy/duplication is trickier.
> this is what i got so far:
[snip]
> I'm lost as to what is missing here.
> any help would be greatly appreciated.

An SSL structure represents the actual connection itself. The connection
cannot be duplicated -- there is no way to turn one connection into two
identical connections. So what you're trying to do does not make logical
sense.

If you want to have two handles to the connection, such that the same single
connection can be used from two different places, what you want is a
structure that acts as a handle to a connection. You can then safely
duplicate *this* structure, since it now represents a "way to get to a
connection", which you can logically have more than one of.

SSL structures are already reference count, but there's no easy way to
increment it. So you may want to use your own reference count. Create two
structures, one that holds the SSL pointer and a reference count, and
another one that contains pointers to that first structure. It's that second
structure that you can use as a hook to an SSL connection and safely
duplicate. When the second structure is destroyed, dec the ref count on the
first structure, and if it hits zero, SSL_free the underlying SSL object.

DS


______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to