Changeset babdb29 in mod_gnutls
- Timestamp:
- May 16, 2018, 2:12:08 AM (5 years ago)
- Branches:
- asyncio, debian/master, main, master, proxy-ticket
- Children:
- 92b5f4d
- Parents:
- d036f96
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
include/mod_gnutls.h.in
rd036f96 rbabdb29 182 182 /* Mutex to prevent parallel OCSP requests */ 183 183 apr_global_mutex_t *ocsp_mutex; 184 /* Enable OCSP cache */ 185 unsigned char ocsp_cache_enable : 2; 186 /* Internal OCSP cache data */ 187 mgs_cache_t ocsp_cache; 184 188 /* Cache timeout for OCSP responses. Note that the nextUpdate 185 189 * field of the response takes precedence if shorter. */ -
src/gnutls_cache.c
rd036f96 rbabdb29 31 31 #include "mod_gnutls.h" 32 32 #include "gnutls_config.h" 33 #include "gnutls_ocsp.h" 33 34 34 35 #include <ap_socache.h> … … 414 415 mgs_srvconf_rec *sc = (mgs_srvconf_rec *) 415 416 ap_get_module_config(s->module_config, &gnutls_module); 416 ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, s, 417 "Cleaning up socache '%s:%s'", 418 sc->cache->prov->name, sc->cache->config); 419 sc->cache->prov->destroy(sc->cache->socache, s); 417 if (sc->cache) 418 { 419 ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, s, 420 "Cleaning up session cache '%s:%s'", 421 sc->cache->prov->name, sc->cache->config); 422 sc->cache->prov->destroy(sc->cache->socache, s); 423 } 424 if (sc->ocsp_cache) 425 { 426 ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, s, 427 "Cleaning up OCSP cache '%s:%s'", 428 sc->ocsp_cache->prov->name, sc->ocsp_cache->config); 429 sc->ocsp_cache->prov->destroy(sc->ocsp_cache->socache, s); 430 } 420 431 return APR_SUCCESS; 421 432 } … … 428 439 { 429 440 apr_status_t rv = APR_SUCCESS; 441 442 /* Initialize the OCSP cache first so it's not skipped if the 443 * session cache is disabled. */ 444 if (sc->ocsp_cache != NULL) 445 { 446 /* TODO: Maybe initialize only if explicitly enabled OR at 447 * least one (virtual) host has OCSP enabled? */ 448 rv = mgs_cache_inst_init(sc->ocsp_cache, MGS_OCSP_CACHE_NAME, 449 MGS_OCSP_CACHE_MUTEX_NAME, s, pconf); 450 if (rv != APR_SUCCESS) 451 return HTTP_INSUFFICIENT_STORAGE; 452 } 453 430 454 /* GnuTLSCache was never explicitly set or is disabled: */ 431 455 if (sc->cache_enable == GNUTLS_ENABLED_UNSET … … 450 474 } 451 475 452 int mgs_cache_child_init(apr_pool_t * p, 453 server_rec * s, 454 mgs_srvconf_rec * sc) 476 int mgs_cache_child_init(apr_pool_t *p, server_rec *server, 477 mgs_cache_t cache, const char *mutex_name) 455 478 { 456 479 /* reinit cache mutex */ 457 const char *lockfile = apr_global_mutex_lockfile( sc->cache->mutex);458 apr_status_t rv = apr_global_mutex_child_init(& sc->cache->mutex,480 const char *lockfile = apr_global_mutex_lockfile(cache->mutex); 481 apr_status_t rv = apr_global_mutex_child_init(&cache->mutex, 459 482 lockfile, p); 460 483 if (rv != APR_SUCCESS) 461 ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s ,462 "Failed to reinit mutex '%s'", MGS_CACHE_MUTEX_NAME);463 464 return 0;484 ap_log_error(APLOG_MARK, APLOG_EMERG, rv, server, 485 "Failed to reinit mutex '%s'", mutex_name); 486 487 return rv; 465 488 } 466 489 -
src/gnutls_cache.h
rd036f96 rbabdb29 81 81 * @param s default server of the Apache configuration, head of the 82 82 * server list 83 * @param sc mod_gnutls data associated with `s` 83 * @param cache the cache to reinit 84 * @param mutex_name name of the mutex associated with the cache for 85 * logging purposes 84 86 */ 85 int mgs_cache_child_init(apr_pool_t *p, server_rec *s, mgs_srvconf_rec *sc); 87 int mgs_cache_child_init(apr_pool_t *p, server_rec *server, 88 mgs_cache_t cache, const char *mutex_name); 86 89 87 90 /** -
src/gnutls_config.c
rd036f96 rbabdb29 625 625 else if (!strcasecmp(parms->directive->directive, "GnuTLSOCSPCache")) 626 626 { 627 // TODO 628 return NULL; 627 if (enable == GNUTLS_ENABLED_FALSE) 628 { 629 /* TODO: Should this return an error like "use 630 * GnuTLSOCSPStapling off if you want to disable OCSP 631 * stapling"? */ 632 sc->ocsp_cache_enable = GNUTLS_ENABLED_FALSE; 633 return NULL; 634 } 635 sc->ocsp_cache_enable = GNUTLS_ENABLED_TRUE; 636 cache = &sc->ocsp_cache; 629 637 } 630 638 else … … 899 907 sc->ocsp_response_file = NULL; 900 908 sc->ocsp_mutex = NULL; 909 sc->ocsp_cache_enable = GNUTLS_ENABLED_UNSET; 910 sc->ocsp_cache = NULL; 901 911 sc->ocsp_cache_time = MGS_TIMEOUT_UNSET; 902 912 sc->ocsp_failure_timeout = MGS_TIMEOUT_UNSET; -
src/gnutls_hooks.c
rd036f96 rbabdb29 130 130 ap_mutex_register(pconf, MGS_CACHE_MUTEX_NAME, NULL, APR_LOCK_DEFAULT, 0); 131 131 ap_mutex_register(pconf, MGS_OCSP_MUTEX_NAME, NULL, APR_LOCK_DEFAULT, 0); 132 ap_mutex_register(pconf, MGS_OCSP_CACHE_MUTEX_NAME, NULL, 133 APR_LOCK_DEFAULT, 0); 132 134 133 135 /* Register a pool clean-up function */ … … 633 635 if (sc->cache_timeout == MGS_TIMEOUT_UNSET) 634 636 sc->cache_timeout = sc_base->cache_timeout; 637 sc->ocsp_cache_enable = sc_base->ocsp_cache_enable; 638 sc->ocsp_cache = sc_base->ocsp_cache; 635 639 636 640 sc->singleton_wd = sc_base->singleton_wd; … … 775 779 } 776 780 777 if (sc->cache_enable) { 778 rv = mgs_cache_child_init(p, s, sc); 779 if (rv != APR_SUCCESS) { 781 if (sc->cache_enable == GNUTLS_ENABLED_TRUE) 782 { 783 rv = mgs_cache_child_init(p, s, sc->cache, MGS_CACHE_MUTEX_NAME); 784 if (rv != APR_SUCCESS) 780 785 ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, 781 "GnuTLS: Failed to run Cache Init"); 782 } 783 } 784 785 /* reinit OCSP mutex */ 786 "Child init for session cache failed!"); 787 } 788 789 if (sc->ocsp_cache_enable == GNUTLS_ENABLED_TRUE) 790 { 791 rv = mgs_cache_child_init(p, s, sc->ocsp_cache, 792 MGS_OCSP_CACHE_MUTEX_NAME); 793 if (rv != APR_SUCCESS) 794 ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, 795 "Child init for OCSP cache failed!"); 796 } 797 798 /* reinit OCSP request mutex */ 786 799 const char *lockfile = apr_global_mutex_lockfile(sc->ocsp_mutex); 787 800 rv = apr_global_mutex_child_init(&sc->ocsp_mutex, lockfile, p); -
src/gnutls_ocsp.h
rd036f96 rbabdb29 24 24 25 25 #define MGS_OCSP_MUTEX_NAME "gnutls-ocsp" 26 #define MGS_OCSP_CACHE_MUTEX_NAME "gnutls-ocsp-cache" 27 #define MGS_OCSP_CACHE_NAME "gnutls_ocsp" 26 28 27 29 /** Default OCSP response cache timeout in seconds */
Note: See TracChangeset
for help on using the changeset viewer.