From 557cfead262e322aa93fa52a10eee3e5b5d2e325 Mon Sep 17 00:00:00 2001 From: Jim Jagielski Date: Tue, 8 Jul 2014 13:13:49 +0000 Subject: [PATCH] Merge r1583191, r1584098, r1584665, r1591401 from trunk: mod_ssl: send OCSP request's nonce according to SSLOCSPUseRequestNonce on/off. PR 56233. mod_ssl: follow up to r1583191. New SSLOCSPUseRequestNonce directive's manual and CHANGES. Non functional code changes (modssl_ctx_t's field ocsp_use_request_nonce grouped with other OCSP ones, nested if turned to a single AND condition). Remove SSLOCSPUseRequestNonce OpenSSL-0.9.7 requirement (0.9.8 already required by httpd-2.4) and set availability to 2.5-dev until further notice. mod_ssl: follow up to r1583191. Use type BOOL for modssl_ctx_t's field ocsp_use_request_nonce. Suggested by: kbrand. Submitted by: ylavic Reviewed/backported by: jim git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1608758 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 4 ++++ docs/manual/mod/mod_ssl.xml | 17 +++++++++++++++++ modules/ssl/mod_ssl.c | 2 ++ modules/ssl/ssl_engine_config.c | 11 +++++++++++ modules/ssl/ssl_engine_ocsp.c | 21 ++++++++++++--------- modules/ssl/ssl_private.h | 3 +++ 6 files changed, 49 insertions(+), 9 deletions(-) diff --git a/CHANGES b/CHANGES index 943c48b6a4..d31a0a7d7b 100644 --- a/CHANGES +++ b/CHANGES @@ -71,6 +71,10 @@ Changes with Apache 2.4.10 programs to the form used in releases up to 2.4.7, and emulate a backwards-compatible behavior for existing setups. [Kaspar Brand] + *) mod_ssl: Add SSLOCSPUseRequestNonce directive to control whether or not + OCSP requests should use a nonce to be checked against the responder's + one. PR 56233. [Yann Ylavic, Kaspar Brand] + *) mod_lua: Enforce the max post size allowed via r:parsebody() [Daniel Gruno] diff --git a/docs/manual/mod/mod_ssl.xml b/docs/manual/mod/mod_ssl.xml index 9fd0b13cf1..0ee747eab5 100644 --- a/docs/manual/mod/mod_ssl.xml +++ b/docs/manual/mod/mod_ssl.xml @@ -2277,6 +2277,23 @@ which means that OCSP responses are considered valid as long as their + +SSLOCSPUseRequestNonce +Use a nonce within OCSP queries +SSLOCSPUseRequestNonce on|off +SSLOCSPUseRequestNonce on +server config +virtual host +Available in httpd 2.4.10 and later + + +

This option determines whether queries to OCSP responders should contain +a nonce or not. By default, a query nonce is always used and checked against +the response's one. When the responder does not use nonces (eg. Microsoft OCSP +Responder), this option ought to be turned off.

+
+
+ SSLInsecureRenegotiation Option to enable support for insecure renegotiation diff --git a/modules/ssl/mod_ssl.c b/modules/ssl/mod_ssl.c index 6e632a3803..316dc6504e 100644 --- a/modules/ssl/mod_ssl.c +++ b/modules/ssl/mod_ssl.c @@ -233,6 +233,8 @@ static const command_rec ssl_config_cmds[] = { "Maximum age of OCSP responses") SSL_CMD_SRV(OCSPResponderTimeout, TAKE1, "OCSP responder query timeout") + SSL_CMD_SRV(OCSPUseRequestNonce, FLAG, + "Whether OCSP queries use a nonce or not ('on', 'off')") #ifdef HAVE_OCSP_STAPLING /* diff --git a/modules/ssl/ssl_engine_config.c b/modules/ssl/ssl_engine_config.c index 6fa8d0b05f..ccff11aae6 100644 --- a/modules/ssl/ssl_engine_config.c +++ b/modules/ssl/ssl_engine_config.c @@ -133,6 +133,7 @@ static void modssl_ctx_init(modssl_ctx_t *mctx, apr_pool_t *p) mctx->ocsp_resptime_skew = UNSET; mctx->ocsp_resp_maxage = UNSET; mctx->ocsp_responder_timeout = UNSET; + mctx->ocsp_use_request_nonce = UNSET; #ifdef HAVE_OCSP_STAPLING mctx->stapling_enabled = UNSET; @@ -275,6 +276,7 @@ static void modssl_ctx_cfg_merge(apr_pool_t *p, cfgMergeInt(ocsp_resptime_skew); cfgMergeInt(ocsp_resp_maxage); cfgMergeInt(ocsp_responder_timeout); + cfgMergeBool(ocsp_use_request_nonce); #ifdef HAVE_OCSP_STAPLING cfgMergeBool(stapling_enabled); cfgMergeInt(stapling_resptime_skew); @@ -1625,6 +1627,15 @@ const char *ssl_cmd_SSLOCSPResponderTimeout(cmd_parms *cmd, void *dcfg, const ch return NULL; } +const char *ssl_cmd_SSLOCSPUseRequestNonce(cmd_parms *cmd, void *dcfg, int flag) +{ + SSLSrvConfigRec *sc = mySrvConfig(cmd->server); + + sc->server->ocsp_use_request_nonce = flag ? TRUE : FALSE; + + return NULL; +} + const char *ssl_cmd_SSLProxyCheckPeerExpire(cmd_parms *cmd, void *dcfg, int flag) { SSLSrvConfigRec *sc = mySrvConfig(cmd->server); diff --git a/modules/ssl/ssl_engine_ocsp.c b/modules/ssl/ssl_engine_ocsp.c index 90da5c279f..0ac223ac03 100644 --- a/modules/ssl/ssl_engine_ocsp.c +++ b/modules/ssl/ssl_engine_ocsp.c @@ -104,7 +104,8 @@ static apr_uri_t *determine_responder_uri(SSLSrvConfigRec *sc, X509 *cert, * request object on success, or NULL on error. */ static OCSP_REQUEST *create_request(X509_STORE_CTX *ctx, X509 *cert, OCSP_CERTID **certid, - server_rec *s, apr_pool_t *p) + server_rec *s, apr_pool_t *p, + SSLSrvConfigRec *sc) { OCSP_REQUEST *req = OCSP_REQUEST_new(); @@ -116,7 +117,9 @@ static OCSP_REQUEST *create_request(X509_STORE_CTX *ctx, X509 *cert, return NULL; } - OCSP_request_add1_nonce(req, 0, -1); + if (sc->server->ocsp_use_request_nonce != FALSE) { + OCSP_request_add1_nonce(req, 0, -1); + } return req; } @@ -139,7 +142,7 @@ static int verify_ocsp_status(X509 *cert, X509_STORE_CTX *ctx, conn_rec *c, return V_OCSP_CERTSTATUS_UNKNOWN; } - request = create_request(ctx, cert, &certID, s, pool); + request = create_request(ctx, cert, &certID, s, pool, sc); if (request) { apr_interval_time_t to = sc->server->ocsp_responder_timeout == UNSET ? apr_time_from_sec(DEFAULT_OCSP_TIMEOUT) : @@ -171,12 +174,12 @@ static int verify_ocsp_status(X509 *cert, X509_STORE_CTX *ctx, conn_rec *c, } } - if (rc == V_OCSP_CERTSTATUS_GOOD) { - if (OCSP_check_nonce(request, basicResponse) != 1) { - ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, APLOGNO(01924) - "Bad OCSP responder answer (bad nonce)"); - rc = V_OCSP_CERTSTATUS_UNKNOWN; - } + if (rc == V_OCSP_CERTSTATUS_GOOD && + sc->server->ocsp_use_request_nonce != FALSE && + OCSP_check_nonce(request, basicResponse) != 1) { + ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, APLOGNO(01924) + "Bad OCSP responder answer (bad nonce)"); + rc = V_OCSP_CERTSTATUS_UNKNOWN; } if (rc == V_OCSP_CERTSTATUS_GOOD) { diff --git a/modules/ssl/ssl_private.h b/modules/ssl/ssl_private.h index f7a193bfa1..101ac40663 100644 --- a/modules/ssl/ssl_private.h +++ b/modules/ssl/ssl_private.h @@ -609,6 +609,8 @@ typedef struct { long ocsp_resptime_skew; long ocsp_resp_maxage; apr_interval_time_t ocsp_responder_timeout; + BOOL ocsp_use_request_nonce; + #ifdef HAVE_SSL_CONF_CMD SSL_CONF_CTX *ssl_ctx_config; /* Configuration context */ apr_array_header_t *ssl_ctx_param; /* parameters to pass to SSL_CTX */ @@ -730,6 +732,7 @@ const char *ssl_cmd_SSLOCSPDefaultResponder(cmd_parms *cmd, void *dcfg, const ch const char *ssl_cmd_SSLOCSPResponseTimeSkew(cmd_parms *cmd, void *dcfg, const char *arg); const char *ssl_cmd_SSLOCSPResponseMaxAge(cmd_parms *cmd, void *dcfg, const char *arg); const char *ssl_cmd_SSLOCSPResponderTimeout(cmd_parms *cmd, void *dcfg, const char *arg); +const char *ssl_cmd_SSLOCSPUseRequestNonce(cmd_parms *cmd, void *dcfg, int flag); const char *ssl_cmd_SSLOCSPEnable(cmd_parms *cmd, void *dcfg, int flag); #ifdef HAVE_SSL_CONF_CMD -- 2.50.1