Changeset 14548b9 in mod_gnutls
- Timestamp:
- Dec 5, 2016, 4:02:30 PM (6 years ago)
- Branches:
- asyncio, debian/master, debian/stretch-backports, main, master, proxy-ticket, upstream
- Children:
- 104e881
- Parents:
- d4d066f
- git-author:
- Thomas Klute <thomas2.klute@…> (12/05/16 16:01:23)
- git-committer:
- Thomas Klute <thomas2.klute@…> (12/05/16 16:02:30)
- Location:
- src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/gnutls_cache.c
rd4d066f r14548b9 1 /* *1 /* 2 2 * Copyright 2004-2005 Paul Querna 3 3 * Copyright 2008 Nikos Mavrogiannopoulos … … 16 16 * See the License for the specific language governing permissions and 17 17 * limitations under the License. 18 *19 18 */ 20 19 21 /*** 22 * The signatures of the (dbm|mc)_cache_...() functions may be a bit 20 /** 21 * @file gnutls_cache.c 22 * 23 * The signatures of the `(dbm|mc)_cache_...()` functions may be a bit 23 24 * confusing: "store" and "expire" take a server_rec, "fetch" an 24 * mgs_handle_t, and "delete" the void*required for a25 * gnutls_db_remove_func. The first two have matching ..._session25 * mgs_handle_t, and "delete" the `void*` required for a 26 * `gnutls_db_remove_func`. The first two have matching `..._session` 26 27 * functions to fit their respective GnuTLS session cache signatures. 27 28 * 28 29 * This is because "store", "expire" (dbm only), and "fetch" are also 29 * needed for the OCSP cache. Their ..._sessionvariants have been30 * needed for the OCSP cache. Their `..._session` variants have been 30 31 * created to take care of the session cache specific parts, mainly 31 32 * calculating the DB key from the session ID. They have to match the 32 33 * appropriate GnuTLS DB function signatures. 33 34 * 34 * Additionally, there are the mc_cache_(store|fetch)_generic()35 * Additionally, there are the `mc_cache_(store|fetch)_generic()` 35 36 * functions. They exist because memcached requires string keys while 36 37 * DBM accepts binary keys, and provide wrappers to turn binary keys 37 * into hex strings with a "mod_gnutls:"prefix.38 * into hex strings with a `mod_gnutls:` prefix. 38 39 * 39 40 * To update cached OCSP responses independent of client connections, … … 41 42 * the other hand "fetch" does not need to do that, because cached 42 43 * OCSP responses will be retrieved for use in client connections. 43 * **/44 */ 44 45 45 46 #include "gnutls_cache.h" … … 64 65 #endif 65 66 66 /* defaultcache timeout */67 /** Default session cache timeout */ 67 68 #define MGS_DEFAULT_CACHE_TIMEOUT 300 68 69 69 /* it seems the default has some strange errors. Use SDBM 70 */ 70 /** Prefix for keys used with a memcached cache */ 71 71 #define MC_TAG "mod_gnutls:" 72 /* two characters per byte, plus one more for '\0' */ 72 /** Maximum length of the hex string representation of a GnuTLS 73 * session ID: two characters per byte, plus one more for `\0` */ 73 74 #if GNUTLS_VERSION_NUMBER >= 0x030400 74 75 #define GNUTLS_SESSION_ID_STRING_LEN ((GNUTLS_MAX_SESSION_ID_SIZE * 2) + 1) … … 85 86 #endif 86 87 87 /* Name the Session ID as: 88 * server:port.SessionID 89 * to disallow resuming sessions on different servers 88 /** 89 * Turn a GnuTLS session ID into the key format we use with DBM 90 * caches. Name the Session ID as `server:port.SessionID` to disallow 91 * resuming sessions on different servers. 92 * 93 * @return `0` on success, `-1` on failure 90 94 */ 91 95 static int mgs_session_id2dbm(conn_rec *c, unsigned char *id, int idlen, … … 106 110 } 107 111 108 /* The OPENSSL_TIME_FORMAT macro and mgs_time2sz() serve to print time109 * in a format compatible with OpenSSL's ASN1_TIME_print()112 /** The OPENSSL_TIME_FORMAT macro and mgs_time2sz() serve to print 113 * time in a format compatible with OpenSSL's `ASN1_TIME_print()` 110 114 * function. */ 111 112 115 #define OPENSSL_TIME_FORMAT "%b %d %k:%M:%S %Y %Z" 113 116 … … 128 131 #if HAVE_APR_MEMCACHE 129 132 130 /* Name the Session ID as: 131 * server:port.SessionID 132 * to disallow resuming sessions on different servers 133 /** 134 * Turn a GnuTLS session ID into the key format we use with memcached 135 * caches. Name the Session ID as `server:port.SessionID` to disallow 136 * resuming sessions on different servers. 137 * 138 * @return `0` on success, `-1` on failure 133 139 */ 134 140 static char *mgs_session_id2mc(conn_rec * c, unsigned char *id, int idlen) -
src/gnutls_cache.h
rd4d066f r14548b9 1 /* *1 /* 2 2 * Copyright 2004-2005 Paul Querna 3 3 * Copyright 2014 Nikos Mavrogiannopoulos … … 15 15 * See the License for the specific language governing permissions and 16 16 * limitations under the License. 17 */ 18 19 /** 20 * @file 17 21 * 22 * Generic object cache for mod_gnutls 18 23 */ 19 24 … … 24 29 #include <httpd.h> 25 30 31 /** Name of the mod_gnutls cache access mutex, for use with Apache's 32 * `Mutex` directive */ 26 33 #define MGS_CACHE_MUTEX_NAME "gnutls-cache" 27 34 28 35 /** 29 * Init the Cache after Configuration is done 36 * Initialize the internal cache configuration structure. This 37 * function is called after the configuration file(s) have been 38 * parsed. 30 39 */ 31 40 int mgs_cache_post_config(apr_pool_t *p, server_rec *s, mgs_srvconf_rec *sc); 32 41 33 42 /** 34 * Init the Cache inside each Process43 * (Re-)Initialize the cache in a child process after forking 35 44 */ 36 45 int mgs_cache_child_init(apr_pool_t *p, server_rec *s, mgs_srvconf_rec *sc); 37 46 38 47 /** 39 * Setup the Session Caching 48 * Setup caching for the given TLS session 49 * 50 * @param ctxt mod_gnutls session context 51 * @return 0 40 52 */ 41 53 int mgs_cache_session_init(mgs_handle_t *ctxt); … … 44 56 45 57 /** 46 * Convert a time_tinto a null terminated string in a format47 * compatible with OpenSSL's ASN1_TIME_print()58 * Convert a `time_t` into a null terminated string in a format 59 * compatible with OpenSSL's `ASN1_TIME_print()` 48 60 * 49 61 * @param t time_t time 50 62 * @param str Location to store the time string 51 * @param strsize The maximum length that can be stored in str 63 * @param strsize The maximum length that can be stored in `str` 64 * @return `str` 52 65 */ 53 66 char *mgs_time2sz(time_t t, char *str, int strsize); 54 67 55 /* 56 * Generic object cache functions, used for OCSP caching 68 /** 69 * Generic store function for the mod_gnutls object cache 70 * 71 * @param s server associated with the cache entry 72 * @param key key for the cache entry 73 * @param data data to be cached 74 * @param expiry expiration time 75 * @return -1 on error, 0 on success 57 76 */ 58 77 typedef int (*cache_store_func)(server_rec *s, gnutls_datum_t key, 59 78 gnutls_datum_t data, apr_time_t expiry); 79 /** 80 * Generic fetch function for the mod_gnutls object cache 81 * 82 * @param ctxt mod_gnutls session context for the request 83 * @param key key for the cache entry to be fetched 84 * @return the requested cache entry, or `{NULL, 0}` 85 */ 60 86 typedef gnutls_datum_t (*cache_fetch_func)(mgs_handle_t *ctxt, 61 87 gnutls_datum_t key); 88 /** 89 * Internal cache configuration structure 90 */ 62 91 struct mgs_cache { 92 /** Store function for this cache */ 63 93 cache_store_func store; 94 /** Fetch function for this cache */ 64 95 cache_fetch_func fetch; 65 /* Mutex for cache access (used only if the cache type is not96 /** Mutex for cache access (used only if the cache type is not 66 97 * thread-safe) */ 67 98 apr_global_mutex_t *mutex;
Note: See TracChangeset
for help on using the changeset viewer.