]> git.ipfire.org Git - thirdparty/postfix.git/commitdiff
Bitrot: SSL_SESSION opaque in OpenSSL 1.1.0
authorViktor Dukhovni <postfix-users@dukhovni.org>
Sun, 10 Jan 2016 08:37:38 +0000 (03:37 -0500)
committerViktor Dukhovni <postfix-users@dukhovni.org>
Sun, 10 Jan 2016 17:21:06 +0000 (12:21 -0500)
postfix/src/tls/tls_server.c

index 441d24ca2a1db9e22b5557bd5c857404c33623ff..69b071eab4f6daa2f66af52697636cecaaf3f54d 100644 (file)
   */
 static const char server_session_id_context[] = "Postfix/TLS";
 
+#if OPENSSL_VERSION_NUMBER >= 0x1000000fL
+#define GET_SID(s, v, lptr)    ((v) = SSL_SESSION_get_id((s), (lptr)))
+
+#else                                  /* Older OpenSSL releases */
+#define GET_SID(s, v, lptr) \
+    do { (v) = (s)->session_id; *(lptr) = (s)->session_id_length; } while (0)
+
+#endif                                 /* OPENSSL_VERSION_NUMBER */
+
 /* get_server_session_cb - callback to retrieve session from server cache */
 
 static SSL_SESSION *get_server_session_cb(SSL *ssl, unsigned char *session_id,
@@ -221,14 +230,16 @@ static void uncache_session(SSL_CTX *ctx, TLS_SESS_STATE *TLScontext)
 {
     VSTRING *cache_id;
     SSL_SESSION *session = SSL_get_session(TLScontext->con);
+    const unsigned char *sid;
+    unsigned int sid_length;
 
     SSL_CTX_remove_session(ctx, session);
 
     if (TLScontext->cache_type == 0)
        return;
 
-    GEN_CACHE_ID(cache_id, session->session_id, session->session_id_length,
-                TLScontext->serverid);
+    GET_SID(session, sid, &sid_length);
+    GEN_CACHE_ID(cache_id, sid, sid_length, TLScontext->serverid);
 
     if (TLScontext->log_mask & TLS_LOG_CACHE)
        msg_info("%s: remove session %s from %s cache", TLScontext->namaddr,
@@ -246,12 +257,14 @@ static int new_server_session_cb(SSL *ssl, SSL_SESSION *session)
     VSTRING *cache_id;
     TLS_SESS_STATE *TLScontext;
     VSTRING *session_data;
+    const unsigned char *sid;
+    unsigned int sid_length;
 
     if ((TLScontext = SSL_get_ex_data(ssl, TLScontext_index)) == 0)
        msg_panic("%s: null TLScontext in new session callback", myname);
 
-    GEN_CACHE_ID(cache_id, session->session_id, session->session_id_length,
-                TLScontext->serverid);
+    GET_SID(session, sid, &sid_length);
+    GEN_CACHE_ID(cache_id, sid, sid_length, TLScontext->serverid);
 
     if (TLScontext->log_mask & TLS_LOG_CACHE)
        msg_info("%s: save session %s to %s cache", TLScontext->namaddr,