Changeset 33d812d in mod_gnutls


Ignore:
Timestamp:
May 26, 2020, 4:24:47 PM (3 years ago)
Author:
Fiona Klute <fiona.klute@…>
Branches:
asyncio, main, master, proxy-ticket
Children:
b14f6ae
Parents:
15ce4db
Message:

Retrieve received session tickets

The tickets aren't used yet. Making the handshake hook function work
requires a little rearrangement: GnuTLS supports only one handshake
hook function on a session, so the early SNI hook must be enabled only
on server session, and the new ticket hook only on client (proxy)
sessions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/gnutls_hooks.c

    r15ce4db r33d812d  
    11301130}
    11311131
     1132static int got_ticket_func(gnutls_session_t session,
     1133                           unsigned int htype,
     1134                           unsigned when,
     1135                           unsigned int incoming __attribute__((unused)),
     1136                           const gnutls_datum_t *msg __attribute__((unused)))
     1137{
     1138    /* Ignore all unexpected messages */
     1139    if (htype != GNUTLS_HANDSHAKE_NEW_SESSION_TICKET
     1140        || when != GNUTLS_HOOK_POST)
     1141        return GNUTLS_E_SUCCESS;
     1142
     1143    mgs_handle_t *ctxt = gnutls_session_get_ptr(session);
     1144    if (!(gnutls_session_get_flags(session) & GNUTLS_SFLAGS_SESSION_TICKET))
     1145    {
     1146        ap_log_cerror(APLOG_MARK, APLOG_WARNING, APR_SUCCESS, ctxt->c,
     1147                      "%s called but session has no ticket!",
     1148                      __func__);
     1149        /* Tickets are optional, so don't break the session on
     1150         * errors. */
     1151        return GNUTLS_E_SUCCESS;
     1152    }
     1153
     1154    gnutls_datum_t dump;
     1155    int ret = gnutls_session_get_data2(session, &dump);
     1156    if (ret != GNUTLS_E_SUCCESS)
     1157    {
     1158        ap_log_cerror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, ctxt->c,
     1159                      "%s: error reading session ticket: %s (%d)",
     1160                      __func__, gnutls_strerror(ret), ret);
     1161        if (dump.data)
     1162            gnutls_free(dump.data);
     1163        return GNUTLS_E_SUCCESS;
     1164    }
     1165
     1166    ap_log_cerror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, ctxt->c,
     1167                  "%s: session ticket read (%u bytes)",
     1168                  __func__, dump.size);
     1169    gnutls_free(dump.data);
     1170    return GNUTLS_E_SUCCESS;
     1171}
     1172
    11321173static void create_gnutls_handle(conn_rec * c)
    11331174{
     
    11561197                          "gnutls_init for proxy connection failed: %s (%d)",
    11571198                          gnutls_strerror(err), err);
     1199        gnutls_handshake_set_hook_function(ctxt->session,
     1200                                           GNUTLS_HANDSHAKE_NEW_SESSION_TICKET,
     1201                                           GNUTLS_HOOK_POST, got_ticket_func);
    11581202    }
    11591203    else
     
    11661210                          "gnutls_init for server side failed: %s (%d)",
    11671211                          gnutls_strerror(err), err);
     1212
     1213        /* Pre-handshake hook for early SNI parsing */
     1214        gnutls_handshake_set_hook_function(ctxt->session,
     1215                                           GNUTLS_HANDSHAKE_CLIENT_HELLO,
     1216                                           GNUTLS_HOOK_PRE, early_sni_hook);
    11681217    }
    11691218
     
    11771226        ap_log_cerror(APLOG_MARK, APLOG_ERR, err, c,
    11781227                      "gnutls_priority_set failed!");
    1179 
    1180     /* Pre-handshake hook for early SNI parsing */
    1181     gnutls_handshake_set_hook_function(ctxt->session,
    1182                                        GNUTLS_HANDSHAKE_CLIENT_HELLO,
    1183                                        GNUTLS_HOOK_PRE, early_sni_hook);
    11841228
    11851229    /* Post client hello hook (called after GnuTLS has parsed it) */
Note: See TracChangeset for help on using the changeset viewer.