wolfssl icon indicating copy to clipboard operation
wolfssl copied to clipboard

CRL Lookup after failing OCSP

Open argold97 opened this issue 5 years ago • 3 comments

In internal.c ProcessPeerCerts() line 10913, the code seems to be structured in such a way if you have both OCSP and CRL enabled Wolf will first attempt to use OCSP to verify a peer cert, and fallback to CRL if OCSP was unsuccessful. However the code never actually allows CRL checking to happen after OCSP:

                        if (ssl->ctx->cm->ocspEnabled &&
                                            ssl->ctx->cm->ocspCheckAll) {
                            WOLFSSL_MSG("Doing Non Leaf OCSP check");
                            ret = CheckCertOCSP_ex(ssl->ctx->cm->ocsp,
                                                    args->dCert, NULL, ssl);
                        #ifdef WOLFSSL_NONBLOCK_OCSP
                            if (ret == OCSP_WANT_READ) {
                                args->lastErr = ret;
                                goto exit_ppc;
                            }
                        #endif
                            doCrlLookup = (ret == OCSP_CERT_UNKNOWN);
                            if (ret != 0) {
                                doCrlLookup = 0;
                                WOLFSSL_MSG("\tOCSP Lookup not ok");
                            }
                        }
                #endif /* HAVE_OCSP */

                #ifdef HAVE_CRL
                        if (ret == 0 && doCrlLookup &&
                                    ssl->ctx->cm->crlEnabled &&
                                                ssl->ctx->cm->crlCheckAll) {

It seems like after OCSP fails it tries to do a CRL check by doing: doCrlLookup = (ret == OCSP_CERT_UNKNOWN) However this is immediately overridden by the next two lines:

                           if (ret != 0) {
                                doCrlLookup = 0;
                                WOLFSSL_MSG("\tOCSP Lookup not ok");
                            }

Furthermore the CRL lookup cannot happen since ret will not be zero when reaching this line:

                #ifdef HAVE_CRL
                        if (ret == 0 && doCrlLookup &&
                                    ssl->ctx->cm->crlEnabled &&
                                                ssl->ctx->cm->crlCheckAll) {

So I can't tell from the code whether doing CRL after failing to do OCSP is the intended use case. If not, is there a way to do this?

argold97 avatar Jun 23 '20 02:06 argold97

Hi @argold97 , thanks for the bug report. We will take a look this and fix. Is there a certificate or website you are using to test against that you can share?

Thanks, David Garske, wolfSSL

dgarske avatar Jun 23 '20 14:06 dgarske

Sorry, the certificates I'm using are private. But it should be easy to make a test certificate to reproduce this issue by creating one with a fake OCSP responder URL. After it fails to connect to this fake responder it should try to do CRL.

argold97 avatar Jun 23 '20 21:06 argold97

@ejohnstown can you assign this maintenance item please. Thanks!

  • KH

kaleb-himes avatar Jun 30 '20 22:06 kaleb-himes

I'm fixing this by restoring the original behavior from 2014, while keeping the existing behavior updates. The original way of doing OCSP then resorting to CRL made the most sense.

ejohnstown avatar Nov 24 '22 00:11 ejohnstown