Changeset e6d9e47 in mod_gnutls for src/gnutls_hooks.c


Ignore:
Timestamp:
Jun 5, 2020, 3:42:56 PM (6 months ago)
Author:
Fiona Klute <fiona.klute@…>
Branches:
master
Children:
796d9a3
Parents:
641d11b
Message:

Move the callback for incoming tickets into gnutls_proxy.c

It's only used for proxy connection, so that's the appropriate
location.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/gnutls_hooks.c

    r641d11b re6d9e47  
    11301130}
    11311131
    1132 static 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     /* No cache means we cannot cache tickets. */
    1155     if (!ctxt->sc->cache_enable)
    1156         return GNUTLS_E_SUCCESS;
    1157 
    1158     gnutls_datum_t ticket;
    1159     int ret = gnutls_session_get_data2(session, &ticket);
    1160     if (ret != GNUTLS_E_SUCCESS)
    1161     {
    1162         ap_log_cerror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, ctxt->c,
    1163                       "%s: error reading session ticket: %s (%d)",
    1164                       __func__, gnutls_strerror(ret), ret);
    1165         if (ticket.data)
    1166             gnutls_free(ticket.data);
    1167         return GNUTLS_E_SUCCESS;
    1168     }
    1169 
    1170     apr_time_t expiry = apr_time_now() + ctxt->sc->cache_timeout;
    1171     ap_log_cerror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, ctxt->c,
    1172                   "%s: caching session ticket for %s (%u bytes)",
    1173                   __func__, ctxt->proxy_ticket_key.data, ticket.size);
    1174     mgs_cache_store(ctxt->sc->cache, ctxt->c->base_server,
    1175                     ctxt->proxy_ticket_key, ticket, expiry);
    1176     gnutls_free(ticket.data);
    1177     return GNUTLS_E_SUCCESS;
    1178 }
    1179 
    11801132static void create_gnutls_handle(conn_rec * c)
    11811133{
     
    12061158        gnutls_handshake_set_hook_function(ctxt->session,
    12071159                                           GNUTLS_HANDSHAKE_NEW_SESSION_TICKET,
    1208                                            GNUTLS_HOOK_POST, got_ticket_func);
     1160                                           GNUTLS_HOOK_POST,
     1161                                           mgs_proxy_got_ticket_func);
    12091162        ctxt->proxy_ticket_key = mgs_proxy_ticket_id(ctxt, NULL);
    12101163    }
Note: See TracChangeset for help on using the changeset viewer.