Tim Bartley <[EMAIL PROTECTED]>:

> Is it possible to have a client session (SSL_SESSION) established for some
> connection persist after that connection has been SSL_free'd so that it can
> be used in a subsequent connection?

> I had a quick look through headers and so on and thought SSL_CTX_add_session
> might do it but that doesn't seem to be the case.

SSL_CTX_add_session, which adds to the session cache, is for servers.
A client can have just one session (you can send only one session ID
in the client_hello, while a server obviously must be prepared to
receive a request for any of various previously established
sesssions).

> Must I always have an open connection referencing the session?

No, you can pass the pointer obtained by SSL_get_session to
i2d_SSL_SESSION to obtain a BER representation of the SSL_SESSION data
structure (well, of most of it).  Then you can keep it in memory,
store it in a disk cache, or whatever you want.  Later d2i_SSL_SESSION
can be used to create an SSL_SESSION data structure from the BER
representation; then you can use SSL_set_session.  (SSL_set_session
increments the reference count of the SSL_SESSION.  Call
SSL_SESSION_free when you no longer need the SSL_SESSION structure).

> Rather than relying on SSL_connect to create the new session should I
> use SSL_SESSION_new to create the session and then call SSL_set_session
> to associate the new session with the new SSL prior to calling SSL_connect?

There's no need to worry about this when you want a new session,
only when you want to reuse a previous session.
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to