Changeset adf36c3 in mod_gnutls
- Timestamp:
- Apr 26, 2018, 2:32:28 AM (3 years ago)
- Branches:
- asyncio, debian/master, master, proxy-ticket
- Children:
- 2f949bc
- Parents:
- 41f9bcb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/gnutls_cache.c
r41f9bcb radf36c3 21 21 * @file gnutls_cache.c 22 22 * 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). 44 28 */ 45 29 … … 68 52 69 53 /** 70 * Turn a GnuTLS session ID into the key format we use with DBM54 * Turn a GnuTLS session ID into the key format we use for 71 55 * caches. Name the Session ID as `server:port.SessionID` to disallow 72 56 * resuming sessions on different servers. … … 153 137 154 138 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 */ 155 152 static int socache_store_session(void *baton, gnutls_datum_t key, 156 153 gnutls_datum_t data) … … 226 223 } 227 224 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 */ 228 242 static gnutls_datum_t socache_fetch_session(void *baton, gnutls_datum_t key) 229 243 { … … 241 255 242 256 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 */ 268 static int socache_delete_session(void *baton, gnutls_datum_t key) 244 269 { 245 270 gnutls_datum_t tmpkey; … … 382 407 } 383 408 384 #include <assert.h>385 386 409 int mgs_cache_session_init(mgs_handle_t * ctxt) 387 410 { … … 391 414 socache_fetch_session); 392 415 gnutls_db_set_remove_function(ctxt->session, 393 socache_delete );416 socache_delete_session); 394 417 gnutls_db_set_store_function(ctxt->session, 395 418 socache_store_session);
Note: See TracChangeset
for help on using the changeset viewer.