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

Function stapling_check_response

src/iocore/net/OCSPStapling.cc:984–1030  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

982}
983
984static int
985stapling_check_response(certinfo *cinf, TS_OCSP_RESPONSE *rsp)
986{
987 int status = TS_OCSP_CERTSTATUS_UNKNOWN, reason;
988 TS_OCSP_BASICRESP *bs = nullptr;
989 ASN1_GENERALIZEDTIME *rev, *thisupd, *nextupd;
990 int response_status = ASN1_ENUMERATED_get(rsp->responseStatus);
991
992 // Check to see if response is an error.
993 // If so we automatically accept it because it would have expired from the cache if it was time to retry.
994 if (response_status != TS_OCSP_RESPONSE_STATUS_SUCCESSFUL) {
995 return SSL_TLSEXT_ERR_NOACK;
996 }
997
998 bs = TS_OCSP_response_get1_basic(rsp);
999 if (bs == nullptr) {
1000 // If we can't parse response just pass it back to client
1001 Error("stapling_check_response: cannot parse response for %s", cinf->certname);
1002 return SSL_TLSEXT_ERR_OK;
1003 }
1004 if (!TS_OCSP_resp_find_status(bs, cinf->cid, &status, &reason, &rev, &thisupd, &nextupd)) {
1005 // If ID not present just pass it back to client
1006 Error("stapling_check_response: certificate ID not present in response for %s", cinf->certname);
1007 } else {
1008 if (!TS_OCSP_check_validity(thisupd, nextupd, 300, -1)) {
1009 // The check is just for logging and pass the response back to client anyway
1010 Error("stapling_check_response: status in response for %s is not valid already/yet", cinf->certname);
1011 }
1012 }
1013
1014 switch (status) {
1015 case TS_OCSP_CERTSTATUS_GOOD:
1016 break;
1017 case TS_OCSP_CERTSTATUS_REVOKED:
1018 Metrics::Counter::increment(ssl_rsb.ocsp_revoked_cert);
1019 break;
1020 case TS_OCSP_CERTSTATUS_UNKNOWN:
1021 Metrics::Counter::increment(ssl_rsb.ocsp_unknown_cert);
1022 break;
1023 default:
1024 break;
1025 }
1026
1027 TS_OCSP_BASICRESP_free(bs);
1028
1029 return SSL_TLSEXT_ERR_OK;
1030}
1031
1032static TS_OCSP_RESPONSE *
1033query_responder(const char *uri, const char *user_agent, TS_OCSP_REQUEST *req, int req_timeout, bool use_get)

Callers 1

Calls 5

TS_OCSP_resp_find_statusFunction · 0.85
TS_OCSP_check_validityFunction · 0.85
incrementFunction · 0.85
ErrorClass · 0.50

Tested by

no test coverage detected