On Mon, Aug 11, 2014 at 01:48:34PM +0200, DEXTER wrote: > 1. If I want session caching on the client side, I have to store the > session manually, to be able to retrieve it when the client connects > to a server and use SSL_set_session() with the stored session.
Correct so far. > The question is, how should I store the session when the client also > uses SNI. Without SNI I could just use ip:port. But when SNI is in > use, it can happen that although the client connects to the same > ip:port, it will be a completely different ssl connection (because a > load balancer rerouted the connection, or it was an apache vhost). > So should I always use ip:port-sni to store the session, or what is > recommended here? Salt the session lookup key with all destination-specific and security-relevant parameters. The Postfix SMTP client uses: ip, port, destination domain, mx hostname, server helo name, protocol mask (SSL_OP_NO_SSLv2 | ...), cipherlist and, if present, the DANE TLSA RRset. In Postfix sessions are shared between multiple processes, and cached by default for an hour, so any of the above can change during that time (newly started processes might be configured differently, ...). You need to figure in your case what information is sufficient in the lookup key to avoid using a cached session that does not meet the security properties you'd want from a new session. > 2. When you use SSL_CTX_set_tlsext_ticket_key_cb (on the server side) to > set a callback to use session tickets, and you store those tickets in > your own cache, how do you make sure the cache will be emptied > regularly (to erase expired tickets)? Does openssl call this cb when > its flusing its own cache, or the user must take care to empty its own > cache regularly? Sesssion tickets should NOT be stored on the server side, only the encryption keys are stored, these should be rotated from time to time. Postfix rotates the encryption keys once an hour, but stores two sets of keys, the previous and the current, so it can validate any unexpired sessions across key rotation. As for the client side cache, yes in a long-lived client cache you also need to keep track of the session's age, and discard sufficiently old sessions. Postfix runs a cache scan periodically, removing stale entries, the cache scan is asynchronous in the event loop to avoid garbage collection stall when the cache is large. -- Viktor. ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org