MCPcopy Create free account
hub / github.com/apache/trafficserver / ssl_callback_ocsp_stapling

Function ssl_callback_ocsp_stapling

src/iocore/net/OCSPStapling.cc:1346–1410  ·  view source on GitHub ↗

RFC 6066 Section-8: Certificate Status Request

Source from the content-addressed store, hash-verified

1344
1345// RFC 6066 Section-8: Certificate Status Request
1346int
1347ssl_callback_ocsp_stapling(SSL *ssl, void *)
1348{
1349 // Assume SSL_get_SSL_CTX() is the same as reaching into the ssl structure
1350 // Using the official call, to avoid leaking internal openssl knowledge
1351 // originally was, cinf = stapling_get_cert_info(ssl->ctx);
1352 certinfo_map *map = stapling_get_cert_info(SSL_get_SSL_CTX(ssl));
1353 if (map == nullptr) {
1354 Dbg(dbg_ctl_ssl_ocsp, "ssl_callback_ocsp_stapling: failed to get certificate map");
1355 return SSL_TLSEXT_ERR_NOACK;
1356 }
1357
1358 if (map->empty()) {
1359 Dbg(dbg_ctl_ssl_ocsp, "ssl_callback_ocsp_stapling: certificate map empty");
1360 return SSL_TLSEXT_ERR_NOACK;
1361 }
1362
1363 // Fetch the specific certificate used in this negotiation
1364 X509 *cert = SSL_get_certificate(ssl);
1365 if (!cert) {
1366 Error("ssl_callback_ocsp_stapling: failed to get certificate");
1367 return SSL_TLSEXT_ERR_NOACK;
1368 }
1369
1370 certinfo *cinf = nullptr;
1371#if HAVE_NATIVE_DUAL_CERT_SUPPORT
1372 certinfo_map::iterator iter = map->find(cert);
1373 if (iter != map->end()) {
1374 cinf = iter->second;
1375 }
1376#else
1377 for (certinfo_map::iterator iter = map->begin(); iter != map->end(); ++iter) {
1378 X509 *key = iter->first;
1379 if (key == nullptr) {
1380 continue;
1381 }
1382
1383 if (X509_cmp(key, cert) == 0) {
1384 cinf = iter->second;
1385 break;
1386 }
1387 }
1388#endif
1389
1390 if (cinf == nullptr) {
1391 Error("ssl_callback_ocsp_stapling: failed to get certificate information for ssl=%p", ssl);
1392 return SSL_TLSEXT_ERR_NOACK;
1393 }
1394
1395 ink_mutex_acquire(&cinf->stapling_mutex);
1396 time_t current_time = time(nullptr);
1397 if ((cinf->resp_derlen == 0 || cinf->is_expire) || (cinf->expire_time < current_time && !cinf->is_prefetched)) {
1398 ink_mutex_release(&cinf->stapling_mutex);
1399 Dbg(dbg_ctl_ssl_ocsp, "ssl_callback_ocsp_stapling: failed to get certificate status for %s", cinf->certname);
1400 return SSL_TLSEXT_ERR_NOACK;
1401 } else {
1402 unsigned char *p = static_cast<unsigned char *>(OPENSSL_malloc(cinf->resp_derlen));
1403 memcpy(p, cinf->resp_der, cinf->resp_derlen);

Callers

nothing calls this directly

Calls 9

stapling_get_cert_infoFunction · 0.85
ink_mutex_acquireFunction · 0.85
ink_mutex_releaseFunction · 0.85
ErrorClass · 0.50
memcpyFunction · 0.50
emptyMethod · 0.45
findMethod · 0.45
endMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected