Changeset adf36c3 in mod_gnutls


Ignore:
Timestamp:
Apr 26, 2018, 2:32:28 AM (19 months ago)
Author:
Fiona Klute <fiona.klute@…>
Branches:
debian/master, master
Children:
2f949bc
Parents:
41f9bcb
Message:

Update documentation in gnutls_cache.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/gnutls_cache.c

    r41f9bcb radf36c3  
    2121 * @file gnutls_cache.c
    2222 *
    23  * The signatures of the `(dbm|mc)_cache_...()` functions may be a bit
    24  * confusing: "store" and "expire" take a server_rec, "fetch" an
    25  * mgs_handle_t, and "delete" the `void*` required for a
    26  * `gnutls_db_remove_func`. The first two have matching `..._session`
    27  * functions to fit their respective GnuTLS session cache signatures.
    28  *
    29  * This is because "store", "expire" (dbm only), and "fetch" are also
    30  * needed for the OCSP cache. Their `..._session` variants have been
    31  * created to take care of the session cache specific parts, mainly
    32  * calculating the DB key from the session ID. They have to match the
    33  * appropriate GnuTLS DB function signatures.
    34  *
    35  * Additionally, there are the `mc_cache_(store|fetch)_generic()`
    36  * functions. They exist because memcached requires string keys while
    37  * DBM accepts binary keys, and provide wrappers to turn binary keys
    38  * into hex strings with a `mod_gnutls:` prefix.
    39  *
    40  * To update cached OCSP responses independent of client connections,
    41  * "store" and "expire" have to work without a connection context. On
    42  * the other hand "fetch" does not need to do that, because cached
    43  * OCSP responses will be retrieved for use in client connections.
     23 * This file contains the cache implementation used for session
     24 * caching and OCSP stapling. The `socache_*_session` functions
     25 * implement the GnuTLS session cache API using the configured cache,
     26 * using mgs_cache_store() and mgs_cache_fetch() as appropriate (see
     27 * gnutls_cache.h).
    4428 */
    4529
     
    6852
    6953/**
    70  * Turn a GnuTLS session ID into the key format we use with DBM
     54 * Turn a GnuTLS session ID into the key format we use for
    7155 * caches. Name the Session ID as `server:port.SessionID` to disallow
    7256 * resuming sessions on different servers.
     
    153137
    154138
     139/**
     140 * Store function for the GnuTLS session cache, see
     141 * gnutls_db_set_store_function().
     142 *
     143 * @param baton mgs_handle_t for the connection, as set via
     144 * gnutls_db_set_ptr()
     145 *
     146 * @param key object key to store
     147 *
     148 * @param data the object to store
     149 *
     150 * @return `0` in case of success, `-1` in case of failure
     151 */
    155152static int socache_store_session(void *baton, gnutls_datum_t key,
    156153                                 gnutls_datum_t data)
     
    226223}
    227224
     225
     226
     227/**
     228 * Fetch function for the GnuTLS session cache, see
     229 * gnutls_db_set_retrieve_function().
     230 *
     231 * *Warning*: The `data` element of the returned `gnutls_datum_t` is
     232 * allocated using `gnutls_malloc()` for compatibility with the GnuTLS
     233 * session caching API, and must be released using `gnutls_free()`.
     234 *
     235 * @param baton mgs_handle_t for the connection, as set via
     236 * gnutls_db_set_ptr()
     237 *
     238 * @param key object key to fetch
     239 *
     240 * @return the requested cache entry, or `{NULL, 0}`
     241 */
    228242static gnutls_datum_t socache_fetch_session(void *baton, gnutls_datum_t key)
    229243{
     
    241255
    242256
    243 static int socache_delete(void *baton, gnutls_datum_t key)
     257/**
     258 * Remove function for the GnuTLS session cache, see
     259 * gnutls_db_set_remove_function().
     260 *
     261 * @param baton mgs_handle_t for the connection, as set via
     262 * gnutls_db_set_ptr()
     263 *
     264 * @param key object key to remove
     265 *
     266 * @return `0` in case of success, `-1` in case of failure
     267 */
     268static int socache_delete_session(void *baton, gnutls_datum_t key)
    244269{
    245270    gnutls_datum_t tmpkey;
     
    382407}
    383408
    384 #include <assert.h>
    385 
    386409int mgs_cache_session_init(mgs_handle_t * ctxt)
    387410{
     
    391414                                        socache_fetch_session);
    392415        gnutls_db_set_remove_function(ctxt->session,
    393                                       socache_delete);
     416                                      socache_delete_session);
    394417        gnutls_db_set_store_function(ctxt->session,
    395418                                     socache_store_session);
Note: See TracChangeset for help on using the changeset viewer.