pki: Use OCSP responder manager for --ocsp --respond

This commit is contained in:
Tobias Brunner 2023-10-30 17:47:34 +01:00
parent dab7c893a6
commit 515cecfe3e

View File

@ -410,11 +410,9 @@ static int ocsp()
if (op == OP_RESPOND) if (op == OP_RESPOND)
{ {
ocsp_responder = lib->get(lib, "ocsp-responder"); ocsp_responder = lib->get(lib, "ocsp-responder");
if (!ocsp_responder) if (ocsp_responder)
{ {
DBG1(DBG_APP, " no ocsp-responder found"); lib->ocsp->add_responder(lib->ocsp, ocsp_responder);
ocsp_status = OCSP_INTERNALERROR;
goto gen;
} }
} }
@ -474,9 +472,9 @@ static int ocsp()
if (issuer_cacert && (issuer_cacert == first_issuer || self_signed)) if (issuer_cacert && (issuer_cacert == first_issuer || self_signed))
{ {
status = ocsp_responder->get_status(ocsp_responder, status = lib->ocsp->get_status(lib->ocsp,
issuer_cacert, serialNumber, issuer_cacert, serialNumber,
&revocationTime, &revocationReason); &revocationTime, &revocationReason);
} }
DBG1(DBG_APP, " certValidation: %N", cert_validation_names, status); DBG1(DBG_APP, " certValidation: %N", cert_validation_names, status);
response->status = status; response->status = status;
@ -556,6 +554,10 @@ gen:
res = 0; res = 0;
end: end:
if (ocsp_responder)
{
lib->ocsp->remove_responder(lib->ocsp, ocsp_responder);
}
DESTROY_IF(key); DESTROY_IF(key);
lib->credmgr->remove_local_set(lib->credmgr, &creds->set); lib->credmgr->remove_local_set(lib->credmgr, &creds->set);
creds->destroy(creds); creds->destroy(creds);