]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
pki: Use OCSP responder manager for --ocsp --respond
authorTobias Brunner <tobias@strongswan.org>
Mon, 30 Oct 2023 16:47:34 +0000 (17:47 +0100)
committerTobias Brunner <tobias@strongswan.org>
Mon, 13 Nov 2023 11:50:22 +0000 (12:50 +0100)
src/pki/commands/ocsp.c

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