Changeset 894efd0 in mod_gnutls for src/gnutls_ocsp.c
- Timestamp:
- Jun 14, 2016, 4:57:36 PM (7 years ago)
- Branches:
- asyncio, debian/master, debian/stretch-backports, main, master, proxy-ticket, upstream
- Children:
- 317b569
- Parents:
- 82745d1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/gnutls_ocsp.c
r82745d1 r894efd0 186 186 * contained in the response, or zero if the response does not contain 187 187 * a nextUpdate field. 188 * 189 * If nonce is not NULL, the response must contain a matching nonce. 188 190 */ 189 191 int check_ocsp_response(server_rec *s, const gnutls_datum_t *ocsp_response, 190 apr_time_t* expiry) 192 apr_time_t* expiry, const gnutls_datum_t *nonce) 193 __attribute__((nonnull(1, 2))); 194 int check_ocsp_response(server_rec *s, const gnutls_datum_t *ocsp_response, 195 apr_time_t* expiry, const gnutls_datum_t *nonce) 191 196 { 192 197 mgs_srvconf_rec *sc = (mgs_srvconf_rec *) … … 248 253 else 249 254 ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, s, 250 "OCSP response is valid."); 255 "OCSP response signature is valid."); 256 } 257 258 if (nonce != NULL) 259 { 260 gnutls_datum_t resp_nonce; 261 ret = gnutls_ocsp_resp_get_nonce(resp, 0, &resp_nonce); 262 if (ret != GNUTLS_E_SUCCESS) 263 { 264 ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s, 265 "Could not get OCSP response nonce: %s (%d)", 266 gnutls_strerror(ret), ret); 267 goto resp_cleanup; 268 } 269 if (resp_nonce.size != nonce->size 270 || memcmp(resp_nonce.data, nonce->data, nonce->size)) 271 { 272 ret = GNUTLS_E_OCSP_RESPONSE_ERROR; 273 ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s, 274 "OCSP response invalid: nonce mismatch"); 275 gnutls_free(resp_nonce.data); 276 goto resp_cleanup; 277 } 278 ap_log_error(APLOG_MARK, APLOG_TRACE2, APR_SUCCESS, s, 279 "OCSP response: nonce match"); 280 gnutls_free(resp_nonce.data); 251 281 } 252 282 … … 534 564 535 565 gnutls_datum_t req; 536 int ret = mgs_create_ocsp_request(s, &req, NULL); 566 gnutls_datum_t nonce; 567 int ret = mgs_create_ocsp_request(s, &req, &nonce); 537 568 if (ret == GNUTLS_E_SUCCESS) 538 569 { … … 545 576 { 546 577 gnutls_free(req.data); 578 gnutls_free(nonce.data); 547 579 apr_pool_destroy(tmp); 548 580 return APR_EGENERAL; … … 555 587 { 556 588 /* do_ocsp_request() does its own error logging. */ 589 gnutls_free(nonce.data); 557 590 apr_pool_destroy(tmp); 558 591 return rv; 559 592 } 560 /* TODO: check nonce */ 561 562 /* TODO: separate option to enable/disable OCSP stapling, restore563 * reading response from file for debugging/expertuse. */593 594 /* TODO: separate option to enable/disable OCSP stapling, same for 595 * nonce, restore reading response from file for debugging/expert 596 * use. */ 564 597 565 598 apr_time_t expiry; 566 if (check_ocsp_response(s, &resp, &expiry ) != GNUTLS_E_SUCCESS)599 if (check_ocsp_response(s, &resp, &expiry, &nonce) != GNUTLS_E_SUCCESS) 567 600 { 568 601 ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_EGENERAL, s, … … 570 603 "update cache."); 571 604 apr_pool_destroy(tmp); 605 gnutls_free(nonce.data); 572 606 return APR_EGENERAL; 573 607 } 608 gnutls_free(nonce.data); 609 574 610 /* If expiry is zero, the response does not contain a nextUpdate 575 611 * field. Use the default cache timeout. */
Note: See TracChangeset
for help on using the changeset viewer.