olga <[EMAIL PROTECTED]>:

[...]
> I have an open socket "s" which should be persistent (should be left
> open for reuse, but may be closed any time by another library -
> wwwlib)

So presumably you're connecting to some HTTPS server.

> I am creating ssl object, setting socket fd to "s", connecting and doing
> read-write fine. Then I do SSL_free on ssl object. 
 
> After some time I need to read from that socket again. I create a
> new ssl with the same socket s. Here is the problem: SSL_connect
> fails(in client_hello()). [...]
> If for second request I create a fresh socket everything works fine.
> I do not understand why this two cases are different [...]

SSL_connect tries to establish a new SSL/TLS connection on the already
used socket, but the server has no reason to expect this.  Either the
previous SSL connection was cleanly terminated with a closure alert,
in which case both sides should just close the connection, or it's
just in the middle of an encrypted conversation.  In neither case the
server is ready to start a completely new SSL conversation; you cannot
reuse a connected socket in this way.  If you want to continue using
the existing connection, you must also use the same OpenSSL object.
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to