Changeset c6dda6d in mod_gnutls
- Timestamp:
- Oct 21, 2016, 6:40:02 PM (6 years ago)
- Branches:
- asyncio, debian/master, debian/stretch-backports, main, master, proxy-ticket, upstream
- Children:
- 333bbc7
- Parents:
- d26fa55
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/mod_gnutls_manual.mdwn
rd26fa55 rc6dda6d 586 586 account for potential clock skew between server, CA, and client, as 587 587 well as transmission time in corner cases. 588 589 ### GnuTLSOCSPFailureTimeout 590 591 EXPERIMENTAL: Wait this many seconds before retrying a failed OCSP request. 592 593 GnuTLSOCSPFailureTimeout SECONDS 594 595 Default: *300*\ 596 Context: server config, virtual host 597 598 Retries of failed OCSP requests must be rate limited to avoid 599 overloading both the server using mod_gnutls and the CA's OCSP 600 responder. A shorter value increases the load on both sides, a longer 601 one means that stapling will remain disabled for longer after a failed 602 request. 588 603 589 604 * * * * * -
include/mod_gnutls.h.in
rd26fa55 rc6dda6d 216 216 * instead of sending a request over HTTP */ 217 217 char *ocsp_response_file; 218 /* Server specific OCSP data*/218 /* Internal OCSP data for this server */ 219 219 mgs_ocsp_data_t ocsp; 220 220 /* Mutex to prevent parallel OCSP requests */ … … 224 224 * valid responses. */ 225 225 apr_time_t ocsp_grace_time; 226 /* If an OCSP request fails wait this long before trying again. */ 227 apr_time_t ocsp_failure_timeout; 226 228 } mgs_srvconf_rec; 227 229 -
src/gnutls_config.c
rd26fa55 rc6dda6d 26 26 /* Default OCSP response grace time in seconds */ 27 27 #define MGS_GRACE_TIME 60 28 /* Default OCSP failure timeout in seconds */ 29 #define MGS_FAILURE_TIMEOUT 300 28 30 29 31 #ifdef APLOG_USE_MODULE … … 870 872 "GnuTLSOCSPGraceTime")) 871 873 sc->ocsp_grace_time = apr_time_from_sec(argint); 874 else if (!apr_strnatcasecmp(parms->directive->directive, 875 "GnuTLSOCSPFailureTimeout")) 876 sc->ocsp_failure_timeout = apr_time_from_sec(argint); 872 877 else 873 878 /* Can't happen unless there's a serious bug in mod_gnutls or Apache */ … … 1123 1128 sc->ocsp_mutex = NULL; 1124 1129 sc->ocsp_grace_time = apr_time_from_sec(MGS_GRACE_TIME); 1130 sc->ocsp_failure_timeout = apr_time_from_sec(MGS_FAILURE_TIMEOUT); 1125 1131 1126 1132 /* this relies on GnuTLS never changing the gnutls_certificate_request_t enum to define -1 */ … … 1183 1189 gnutls_srvconf_assign(ocsp_response_file); 1184 1190 gnutls_srvconf_merge(ocsp_grace_time, apr_time_from_sec(MGS_GRACE_TIME)); 1191 gnutls_srvconf_merge(ocsp_failure_timeout, 1192 apr_time_from_sec(MGS_FAILURE_TIMEOUT)); 1185 1193 1186 1194 gnutls_srvconf_assign(ca_list); -
src/gnutls_ocsp.c
rd26fa55 rc6dda6d 39 39 * or received", not the whole connection. 10 seconds in mod_ssl. */ 40 40 #define OCSP_SOCKET_TIMEOUT 2 41 42 /* Dummy data for failure cache entries (one byte). */ 43 #define OCSP_FAILURE_CACHE_DATA 0x0f 41 44 42 45 … … 684 687 685 688 689 /* 690 * Retries after failed OCSP requests must be rate limited. If the 691 * responder is overloaded or buggy we don't want to add too much more 692 * load, and if a MITM is messing with requests a repetition loop 693 * might end up being a self-inflicted denial of service. 694 */ 695 void mgs_cache_ocsp_failure(server_rec *s) 696 { 697 mgs_srvconf_rec *sc = (mgs_srvconf_rec *) 698 ap_get_module_config(s->module_config, &gnutls_module); 699 700 unsigned char c = OCSP_FAILURE_CACHE_DATA; 701 gnutls_datum_t dummy = { 702 .data = &c, 703 .size = sizeof(c) 704 }; 705 apr_time_t expiry = apr_time_now() + sc->ocsp_failure_timeout; 706 707 char date_str[APR_RFC822_DATE_LEN]; 708 apr_rfc822_date(date_str, expiry); 709 ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, 710 "OCSP request for %s failed, next try after %s.", 711 s->server_hostname, date_str); 712 713 int r = sc->cache->store(s, sc->ocsp->fingerprint, dummy, expiry); 714 if (r != 0) 715 ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s, 716 "Caching OCSP failure failed."); 717 } 718 719 720 686 721 int mgs_get_ocsp_response(gnutls_session_t session __attribute__((unused)), 687 722 void *ptr, … … 702 737 "Fetching OCSP response from cache failed."); 703 738 } 739 else if ((ocsp_response->size == sizeof(unsigned char)) && 740 (*((unsigned char *) ocsp_response->data) == OCSP_FAILURE_CACHE_DATA)) 741 { 742 ap_log_cerror(APLOG_MARK, APLOG_DEBUG, APR_EGENERAL, ctxt->c, 743 "Cached OCSP failure found for %s.", 744 ctxt->c->base_server->server_hostname); 745 goto fail_cleanup; 746 } 704 747 else 705 748 { … … 714 757 "No valid OCSP response in cache, trying to update."); 715 758 716 /* TODO: Once sending OCSP requests is implemented we need a rate717 * limit for retries on error. If the responder is overloaded or718 * buggy we don't want to add too much more load, and if a MITM is719 * messing with requests a repetition loop might end up being a720 * self-inflicted denial of service. */721 759 apr_status_t rv = apr_global_mutex_trylock(ctxt->sc->ocsp_mutex); 722 760 if (APR_STATUS_IS_EBUSY(rv)) … … 747 785 { 748 786 ap_log_cerror(APLOG_MARK, APLOG_ERR, rv, ctxt->c, 749 "Updating OCSP response cache failed"); 787 "Caching a fresh OCSP response failed"); 788 /* cache failure to rate limit retries */ 789 mgs_cache_ocsp_failure(ctxt->c->base_server); 750 790 apr_global_mutex_unlock(ctxt->sc->ocsp_mutex); 751 791 goto fail_cleanup; -
src/mod_gnutls.c
rd26fa55 rc6dda6d 284 284 "EXPERIMENTAL: Replace cached OCSP responses this many " 285 285 "seconds before they expire"), 286 AP_INIT_TAKE1("GnuTLSOCSPFailureTimeout", mgs_set_timeout, 287 NULL, RSRC_CONF, 288 "EXPERIMENTAL: Wait this many seconds before retrying a " 289 "failed OCSP request"), 286 290 #ifdef __clang__ 287 291 /* Workaround for this clang bug:
Note: See TracChangeset
for help on using the changeset viewer.