Skip to content

Allow more than one CRL per name - #12165

Draft
aidankeefe2022 wants to merge 5 commits into
wolfSSL:masterfrom
aidankeefe2022:crl_change
Draft

aidankeefe2022 wants to merge 5 commits into
wolfSSL:masterfrom
aidankeefe2022:crl_change

Conversation

@aidankeefe2022

@aidankeefe2022 aidankeefe2022 commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Zendesk Ticket: https://wolfssl.zendesk.com/agent/tickets/22769

Description

This relies on bringing in the AKID if it exists, along with the issuer hash. This combo is used to try to match a CRL with the cert it is checking. This is also a new flow to the CheckCertCRLList that checks every cert list that shares an issuer to see if it is the best fit. AddCRL no longer rejects unverified CRLs on add and waits until the check to give a verifying CA as much time as possible to load. This is not breaking, just more permissive.

The X509_STORE_add_crl path now tries to verify and dedup on add as well and allows for multiple CRLs to be loaded and deduped if possible. While staying in line with OpenSSL behavior.

Testing

Regression test for the Zendesk report. (This is a large part of the diff becuase like the rest of the file, the Certs and CRLs are inlined)
Minor change to the living test where it no longer errors when it used to.

Checklist

  • added tests

This relies on bringing in the akid along with the issuer hash.
This is also a new flow to the CheckCertCRLList that check every cert
list that shares an issuer to see it it applies. The AddCRL now does not
reject unverified CRLs on add and waits until the check to give as much
time as posible for a verifing CA to be loaded. This is not breaking
just more permissive.

The X509_STORE_add_crl path now tries to verify and dedups on add as well
and allows for muliple CRLs to be loaded and deduped if possible.
While staying inline with openSSL behavior.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A critical CRL-selection flaw allows a newer AKID-mismatched CRL to override an exact match, potentially causing revoked certificates to be accepted.

5 open issues
What changed in this PR

This PR extends wolfSSL’s certificate revocation list (CRL) handling to support multiple signing keys under one issuer name, addressing CA key rollover.

Changes:

  • Uses authority key identifiers alongside issuer names to select CRLs and walk CA chains.
  • Retains unverified CRLs for later verification and shares deduplication logic with X509_STORE_add_crl.
  • Adds rollover regression coverage and updates existing tests for the new behavior and signatures.
File Description
wolfssl/​wolfcrypt/​asn.h Exposes signer key identifiers and issuer lookup for CRL checks.
wolfssl/​crl.h Adds an authority key identifier argument to CRL checking.
wolfcrypt/​src/​asn.c Shares key-aware issuer lookup and preserves signer identifiers.
tests/​unit-mcdc/​test_internal_revocation_whitebox.c Updates CRL-check mocks for the new argument.
tests/​unit-mcdc/​test_crl_whitebox.c Updates white-box CRL-check calls.
tests/​api/​test_certman.h Registers the key-rollover regression test.
tests/​api/​test_certman.c Tests same-name key rollover and adjusts unverified-CRL expectations.
src/​internal.c Uses key-aware issuer traversal during chain revocation checks.
src/​crl.c Implements multi-CRL selection, deferred verification, and shared deduplication.

Review effort: Balanced

Comment thread src/crl.c Resolved
Comment thread src/crl.c Resolved
Comment thread src/crl.c Resolved
Comment thread src/crl.c Resolved
Comment thread tests/api/test_certman.c Resolved
@aidankeefe2022
aidankeefe2022 requested a balanced review from Copilot November 17, 2026 22:53

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #12165

Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-src, wolfssl-bugs
Not reviewed (no scan target covers them): tests/api/test_certman.h
Coverage: 5 of 8 in-scope changed file(s) opened by the reviewer; not opened: tests/unit-mcdc/test_crl_whitebox.c, tests/unit-mcdc/test_internal_revocation_whitebox.c, wolfssl/crl.h

Findings: 2
2 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Review tier: Max

Comment thread src/crl.c Resolved
Comment thread src/crl.c Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical CRL-selection flaws can allow certificate acceptance by ignoring freshness-comparison errors or letting a different-key fallback mask an expired exact-AKID CRL.

2 open issues
5 resolved since last review

Review effort: Balanced

Comment thread src/crl.c Resolved
Comment thread src/crl.c Resolved
Comment thread src/crl.c
Comment on lines +598 to +636
static int CompareCRLnumber(CRL_Entry* prev, CRL_Entry* curr)
{
int ret = 0;
DECL_MP_INT_SIZE_DYN(prev_num, CRL_MAX_NUM_SZ_BITS,
CRL_MAX_NUM_SZ_BITS);
DECL_MP_INT_SIZE_DYN(curr_num, CRL_MAX_NUM_SZ_BITS,
CRL_MAX_NUM_SZ_BITS);

NEW_MP_INT_SIZE(prev_num, CRL_MAX_NUM_SZ_BITS, NULL,
DYNAMIC_TYPE_TMP_BUFFER);
NEW_MP_INT_SIZE(curr_num, CRL_MAX_NUM_SZ_BITS, NULL,
DYNAMIC_TYPE_TMP_BUFFER);
#ifdef MP_INT_SIZE_CHECK_NULL
if ((prev_num == NULL) || (curr_num == NULL)) {
ret = MEMORY_E;
}
#endif

if (ret == 0 && ((INIT_MP_INT_SIZE(prev_num, CRL_MAX_NUM_SZ_BITS)
!= MP_OKAY) || (INIT_MP_INT_SIZE(curr_num,
CRL_MAX_NUM_SZ_BITS)) != MP_OKAY)) {
ret = MP_INIT_E;
}

if (ret == 0 && (mp_read_radix(prev_num, (char*)prev->crlNumber,
MP_RADIX_HEX) != MP_OKAY ||
mp_read_radix(curr_num, (char*)curr->crlNumber,
MP_RADIX_HEX) != MP_OKAY)) {
ret = BAD_FUNC_ARG;
}

if (ret == 0)
ret = mp_cmp(prev_num, curr_num);

FREE_MP_INT_SIZE(prev_num, NULL, DYNAMIC_TYPE_TMP_BUFFER);
FREE_MP_INT_SIZE(curr_num, NULL, DYNAMIC_TYPE_TMP_BUFFER);

return ret;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How big are we expecting CRL numbers to get? We have a 32 bit type. Is that not enough?

@aidankeefe2022 aidankeefe2022 Nov 17, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unsure. This function is preexisting; I just moved it up to be able to use it in CheckCertCRLList

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

found the RFC reason https://www.rfc-editor.org/info/rfc5280/#section-5.2.3

Conforming CRL issuers MUST NOT use CRLNumber
values longer than 20 octets.

Comment thread src/crl.c Outdated
sameAkid = 1;
} else
#endif
/* check that the trust anchor is the same by walking the list */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remind me why we need to check the trust anchor. I thought the CRL was signed by the direct issuer of the cert?

@aidankeefe2022 aidankeefe2022 Nov 17, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the RFC https://www.rfc-editor.org/info/rfc5280/#section-6.3

Obtain and validate the certification path for the issuer of the complete CRL. The trust anchor for the certificate path MUST be the same as the trust anchor used to validate the target certificate.

This is mainly a fallback for no AKID scenarios where a user might load multiple custom CAs with a name like CN=Admin or something

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

CRL handling can replace a valid entry with an expired one and fails to honor VERIFY_SKIP_DATE, causing incorrect certificate-check errors and changing which failures application callbacks can waive.

1 open issue
1 previously missed issue

In code that hasn't changed since last review

Medium severity Expired CRLs replace valid fallback CRLs during deduplication

src/​crl.c:1041

Adding a correctly signed but expired, higher-numbered CRL through X509_STORE_add_crl() now frees an existing unexpired CRL from the same key, because verification enables deduplication without checking nextUpdate. Subsequent certificate checks return CRL_CERT_DATE_ERR instead of using the valid fallback. Keep expired incoming entries from replacing existing entries, while still allowing the add operation to succeed.

2 resolved since last review

Review effort: Balanced

Comment thread src/wolfio.c Resolved

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #12165

Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-src, wolfssl-bugs
Not reviewed (no scan target covers them): tests/api/test_certman.h
Coverage: 3 of 4 in-scope changed file(s) opened by the reviewer; not opened: src/wolfio.c

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Review tier: Lite

Comment thread src/crl.c Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

CRL lookup can let an expired CRL override an earlier successful check and let a superseded CRL incorrectly report a certificate as revoked.

2 open issues
1 resolved since last review

Review effort: Balanced

Comment thread src/crl.c
Comment on lines +786 to +790
*pFoundEntry = 1;
ret = FindRevokedSerial(crle->certs, serial, serialSz,
serialHash, crle->totalCerts);
if (ret != 0)
break;
Comment thread src/crl.c Resolved

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #12165

Scan targets checked: wolfssl-src, wolfssl-bugs
Unchanged since last review (not re-run): wolfcrypt-src, wolfcrypt-bugs
Not reviewed (no scan target covers them): tests/api/test_certman.h
Coverage: 1 of 2 in-scope changed file(s) opened by the reviewer; not opened: src/wolfio.c

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Review tier: Lite

Comment thread src/crl.c
if (!XVALIDATE_DATE(crle->nextDate, crle->nextDateFormat,
ASN_AFTER, MAX_DATE_SIZE)) {
WOLFSSL_MSG("CRL next date is no longer valid");
ret = CRL_CERT_DATE_ERR;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale CRL later in list overrides a valid not-revoked result with CRL_CERT_DATE_ERR · Logic errors

An expired matching CRL sets ret = CRL_CERT_DATE_ERR after an earlier current CRL already set *pFoundEntry = 1 and ret = 0, so the function returns a date error. CheckCertCRLCm skips the crlCb override because foundEntry != 0, so a valid certificate fails depending on list order.

Suggested fix: Record a stale CRL only when no current CRL has matched yet (e.g. if (!*pFoundEntry) ret = CRL_CERT_DATE_ERR;), and clear that error once a current CRL is found.

Related known findings (similar but distinct; listed for context, not part of this finding)

  • F-16319: F-16319 is about a stale CRL's revoked list never being consulted; this is a new PR regression where a stale CRL's date error replaces the success result from another, current CRL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants