Skip to content

Crl Processing Changes: Allow for multiple CRLs per issuer - #12116

Closed
aidankeefe2022 wants to merge 7 commits into
wolfSSL:masterfrom
aidankeefe2022:zendesk-crl
Closed

aidankeefe2022 wants to merge 7 commits into
wolfSSL:masterfrom
aidankeefe2022:zendesk-crl

Conversation

@aidankeefe2022

@aidankeefe2022 aidankeefe2022 commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Description

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

A CA that rolls its signing key keeps the same subject name, so CRLs from both keys share an issuer name. Before this PR, wolfSSL keyed stored CRLs by issuer name alone. A CRL from one key could evict the other key's CRL, or be rejected as a duplicate of it, and the revocations it carried were lost. This PR keys CRLs by issuer name and Authority Key Identifier (AKID), and matches certs to CRLs the same way.

Behavior changes

Storing CRLs (AddCRL, wolfSSL_CertManagerLoadCRL*, wolfSSL_X509_STORE_load_locations)

  • One CRL series per issuer name and signing key. A new CRL replaces a stored one only if both have the same AKID and the new CRL has a higher CRL number. Previously any CRL with the same issuer name was compared, so loading the new key's CRL 1 after the old key's CRL 5 failed with DUPE_ENTRY_E, and loading a higher-numbered CRL from the other key evicted the stored one.
  • CRLs without an AKID form their own series. They are compared with each other but never with CRLs that have an AKID, in either load order. (RFC 5280 5.2.1 requires the AKID, but many deployed CRLs lack one.)
  • "An unverified CRL can't replace a verified one" now applies only within a series. A verified CRL from one key no longer blocks an unverified CRL from another key.
  • The AKID is now stored for every CRL entry. It used to be kept only for entries stored unverified, and DupCRL_Entry cleared it on copies.

Checking a cert (CheckCertCRL*, wolfSSL_CertManagerCheckCRL, handshake)

  • CRLs are split by the cert's AKID into own-key CRLs (AKID matches, or either side has none) and other-key CRLs.
  • Any fresh, verified CRL for the issuer name can revoke, whichever key signed it. Issuer name plus serial number identifies the cert, so a revocation from either key is honored.
  • Only a CRL from the cert's trust anchor can count as coverage (RFC 5280 6.3.3(f)). An own-key CRL decides when one is loaded. Otherwise an other-key CRL counts only if its signer chains to the same trust anchor as the cert's issuer. An other-key CRL from a different anchor can still revoke, but if nothing revokes the cert the result is CRL_MISSING, not success.
  • An expired own-key CRL is not hidden by a fresh other-key CRL. The result is CRL_CERT_DATE_ERR.
  • A stored CRL that fails verification is skipped instead of failing the whole check. This includes a cached failure. Previously the first unverifiable CRL for the issuer name ended the check with its verify error. Now the remaining CRLs decide, and the result is CRL_MISSING if none apply. Callers that tested for ASN_CRL_CONFIRM_E or ASN_CRL_NO_SIGNER_E from a cert check will now see CRL_MISSING or a result from another CRL.

WOLFSSL_CRL_CHECKALL chain walk (ProcessPeerCertsChainCRLCheck)

  • Each CA's issuer is found by AKID, falling back to name, through FindSignerByAkidOrName. Previously GetCAByName returned whichever same-name root sorted first, which could be the root whose CRL isn't loaded.
  • The CA's AKID is passed to the CRL check, so the right key's CRL is used for each step.
  • Cycles are bounded. Two CAs that cross-certify each other are detected and each is checked once. Longer loops stop at WOLFSSL_MAX_CHAIN_DEPTH with ASN_PATHLEN_SIZE_E. Previously a loop of two or more CAs was only stopped by a CRL error.

wolfSSL_X509_STORE_add_crl

  • Entries are merged with the same series rules as a loaded CRL. Previously they were appended to the list. A copy that is no newer than the stored CRL of its series is now dropped, and a newer one replaces it.
  • Entries are checked against the store's CAs before anything is added.
    • Entries that failed verification in the source CertManager are dropped.
    • Entries verified by another CertManager are verified again, since that CertManager may trust different CAs.
    • An entry whose signer isn't in the store yet is kept unverified and checked on use, as a NO_VERIFY load would.
  • The add is all or nothing. If any entry fails its check, X509_STORE_add_crl returns failure and the store is unchanged. The same checks now also run on the first add, when the store has no CRL yet.
  • Copies of entries that were verified at load time can still be checked. Those entries don't keep their signed data. Each CRL entry now records a hash of the key that verified it (verifierKeyHash). A copy is accepted only if the store's signer for it has the same key.
  • The store's write lock is no longer held while signatures are checked.

X509_STORE get_crl callback

  • The application's CRL is no longer pointed at the connection's CertManager. Previously userCrl->cm was overwritten with the connection's CertManager, so one connection's verification result was cached on a CRL object the application might share with connections that use other trust stores. Now the CRL is verified against the connection's CAs on every use, and nothing is cached on it.

Other

  • wolfSSL_X509_CRL_print prints the full 20-byte AKID. It used to stop at the first zero byte, and skipped the AKID entirely when the first byte was zero.
  • test_sk_X509_CRL_encode writes its generated CRLs to certs/crl/gen/ instead of certs/crl/. These CRLs really revoke server-cert.pem and server-ecc.pem, and the example client loads every CRL in certs/crl/, so it would then reject the test servers. scripts/crl-gen-openssl.test now reads from the new path and deletes stale outputs first.

Internal / ABI notes

  • CheckCertCRL_ex takes a new trailing const byte* akid argument (WOLFSSL_LOCAL).
  • FindSignerByAkidOrName is no longer static and returns the cert itself for a self-signed CA. The name-constraint walk already stops on self-signed CAs, so its behavior is unchanged.
  • New GetCATrustAnchor() in ssl_certman.c.
  • Signer.authKeyIdHash and authKeyIdSet now also exist when HAVE_CRL is defined, even with IGNORE_NAME_CONSTRAINTS. CRL_Entry gains verifierKeySet and verifierKeyHash. Both are internal structs, but their layout changes under these configs.

Tests

  • New certman API tests:
    • Key rollover in both load orders and with both CRL-number orderings: same_name_key_rollover.
    • Skipping unverifiable CRLs: skip_unverifiable.
    • X509_STORE_add_crl series rules and copied entries: store_add_same_series, store_add_foreign_verified, store_add_foreign_key.
    • CRL-only signing keys: crl_only_signing_key.
    • Other-key coverage and trust anchors: other_key_fallback, other_key_trust_anchor.
    • A get_crl CRL shared across trust stores: get_crl_cb_shared.
    • The CRL_CHECKALL walk: chain_same_name_key_rollover, chain_walk_follows_akid, chain_walk_cycle.
  • test_wolfSSL_CRL_unverified_no_evict is extended to cover same-series and other-key bogus CRLs.
  • White-box vectors in tests/unit-mcdc/test_crl_whitebox.c cover the AKID decisions in AddCRL and CheckCertCRLList.
  • Fixtures are generated by certs/crl/gen/gen-crl-fixtures.sh into tests/api/test_certman_crl_fixtures.h. They are valid 2026-01-01 to 2046-01-01, and the tests pin the clock with wc_SetTimeCb.

Checklist

  • added tests

@aidankeefe2022 aidankeefe2022 self-assigned this Nov 12, 2026
Copilot AI balanced review requested due to automatic review settings November 12, 2026 23:16

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

An AKID-less CRL update can discard another signing key’s revocations, allowing revoked certificates to pass, and the cycle test does not exercise the new CRL-walk guard.

2 open issues
What changed in this PR

This PR updates wolfSSL’s certificate revocation checks to distinguish CRLs by issuer name and authority key identifier (AKID), supporting issuers with multiple signing keys.

Changes:

  • Keeps separate CRL series for different keys and adds same-name fallback handling.
  • Passes AKIDs through certificate and chain checks, with bounded chain traversal.
  • Adds fixtures and regression tests for key rollover, CRL-only keys, unverifiable CRLs, and cycles.
File Description
wolfssl/​wolfcrypt/​asn.h Makes signer AKID fields available for CRL checks.
wolfssl/​crl.h Adds AKID to the internal CRL-check interface.
wolfcrypt/​src/​asn.c Copies signer AKIDs in CRL-enabled builds.
tests/​unit-mcdc/​test_internal_revocation_whitebox.c Updates CRL mocks for the new argument.
tests/​unit-mcdc/​test_crl_whitebox.c Adds AKID matching and CRL-series test vectors.
tests/​api/​test_certman.h Registers new CRL regression tests.
tests/​api/​test_certman.c Tests rollover, fallback, verification failures, and chain traversal.
tests/​api/​test_certman_crl_fixtures.h Adds certificate, key, and CRL fixtures.
tests/​api/​include.am Includes the fixture header in source distributions.
src/​internal.c Follows issuer AKIDs and bounds CRL chain traversal.
src/​crl.c Updates CRL storage, matching, and fallback behavior.

Review effort: Balanced

Comment thread src/crl.c Resolved
Comment thread src/internal.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 #12116

Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-src, wolfssl-bugs
Not reviewed (no scan target covers them): tests/api/include.am, tests/api/test_certman.h, tests/api/test_certman_crl_fixtures.h
Coverage: 8 of 8 in-scope changed file(s) opened by the reviewer

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

@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 #12116

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/include.am, tests/api/test_certman.h, tests/api/test_certman_crl_fixtures.h
Coverage: 4 of 7 in-scope changed file(s) opened by the reviewer; not opened: src/ssl_certman.c, tests/api.c, tests/api/test_certman.c

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Lite

@wolfSSL-Fenrir-bot
wolfSSL-Fenrir-bot dismissed their stale review November 13, 2026 18:57

Fenrir's latest completed scan found no issues; clearing the prior automated change request.

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

The comment in src/crl.c incorrectly implies that a fresh CRL-only-key CRL can cover an expired own-key CRL despite an AKID mismatch, and needs to describe the verified-CRL and shared-trust-anchor requirements.

1 open issue
2 resolved since last review

Review effort: Balanced

Comment thread src/crl.c Resolved
@aidankeefe2022
aidankeefe2022 requested review from wolfSSL-Fenrir-bot and a balanced review from Copilot November 13, 2026 21:47
@aidankeefe2022
aidankeefe2022 marked this pull request as ready for review November 13, 2026 21:47
@github-actions

Copy link
Copy Markdown

retest this please

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

gcc-arm-cortex-m0plus

  • FLASH: .text +12 B (+0.0%, 71,303 B / 262,144 B, total: 27% used)

gcc-arm-cortex-m3

  • FLASH: .text +28 B (+0.0%, 132,301 B / 262,144 B, total: 50% used)

gcc-arm-cortex-m4-dtls13

  • FLASH: .text +64 B (+0.0%, 197,344 B / 1,048,576 B, total: 19% used)

gcc-arm-cortex-m4-min-ecc

  • FLASH: .text +64 B (+0.1%, 68,561 B / 262,144 B, total: 26% used)

gcc-arm-cortex-m4-openssl-compat

  • FLASH: .text +640 B (+0.1%, 806,020 B / 1,048,576 B, total: 77% used)

gcc-arm-cortex-m4-rsa-only

  • FLASH: .text +448 B (+0.1%, 345,896 B / 1,048,576 B, total: 33% used)

gcc-arm-cortex-m4-sp-math

  • FLASH: .text +64 B (+0.1%, 68,561 B / 262,144 B, total: 26% used)

gcc-arm-cortex-m4-tls12

  • FLASH: .text +64 B (+0.0%, 133,065 B / 262,144 B, total: 51% used)

gcc-arm-cortex-m4-tls13

  • FLASH: .text +64 B (+0.0%, 251,970 B / 262,144 B, total: 96% used)

gcc-arm-cortex-m7-tls13

  • FLASH: .text +64 B (+0.0%, 251,970 B / 262,144 B, total: 96% used)

zephyr-frdm_rw612

  • FLASH: datas +16 B, log_const_area -8 B, rodata +104 B, text +12,160 B (+4.3%, 294,736 B / 67,108,864 B, total: 0% used)
  • RAM: bss +49 B, datas +16 B (+0.1%, 58,423 B / 983,040 B, total: 6% used)

No memory changes detected for:


Catch memory regressions in CI with MemBrowse. Free for open source.

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

The HAVE_CRL and NO_SKID configuration fails to compile or link because it calls the unavailable GetCAByName function instead of GetCA.

1 open issue
1 resolved since last review

Review effort: Balanced

Comment thread src/ssl_certman.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 #12116

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

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Lite

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 replacement can retain superseded revocations, while certificate-cache round-trips omit metadata needed to recognize same-anchor CRLs, causing erroneous CRL_MISSING failures.

2 open issues
1 resolved since last review

Review effort: Balanced

Comment thread src/crl.c Resolved
Comment thread src/crl.c Resolved
@aidankeefe2022 aidankeefe2022 changed the title Match certs with appropriate CRL Crl Processing Changes: Allow for multiple CRLs per issuer and allow more paths to revoke certs Nov 13, 2026
@aidankeefe2022

Copy link
Copy Markdown
Member Author

retest this please

Major change for adding CRLs

They are now only reported as duplicates if the issuer name and AKID do
not match if AKDI is avaible. We then go into out normal checks for CLR
number and date. This means that multiple CRLs from one issuer are added
and we do not miss any revocations.

When checking certs with issuer we match with name and AKID.
If that does not work we then fall back to matching to any
CRL with same issuer name. This can lead to rejecting when we should not
but it is better than accpeting when we should not trade-off.
…that AKIDN mismatch leads to same trust anchor
Now crls with out akids are treated as their own series from same
Issuer. We also now verify the crl later after akid check.

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

The hash-only verification path bypasses cRLSign authorization, and a failed CRL addition can leave the store partially modified.

2 open issues
2 resolved since last review

Review effort: Balanced

Comment thread src/crl.c Resolved
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 #12116

Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-src, wolfssl-bugs
Not reviewed (no scan target covers them): .github/workflows/enterprise.yml, .github/workflows/os-check.yml, .github/workflows/smoke-test.yml, .gitignore, certs/crl/gen/.gitignore, certs/crl/gen/gen-crl-fixtures.sh, certs/crl/include.am, scripts/crl-gen-openssl.test, tests/api/include.am, tests/api/test_certman.h, tests/api/test_certman_crl_fixtures.h
Coverage: 8 of 10 in-scope changed file(s) opened by the reviewer; not opened: src/ssl_certman.c, tests/api.c

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Lite

@aidankeefe2022

Copy link
Copy Markdown
Member Author

@claude review

Comment thread src/crl.c
Comment on lines +1979 to +1983
ret = AddCRL_EntryLocked(crl, ent);
if (ret != 0) {
CRL_Entry_free(ent, crl->heap);
if (ret == WC_NO_ERR_TRACE(DUPE_ENTRY_E))
ret = 0;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 Apps that refresh a CRL with no CRL number through X509_STORE_add_crl now have the newer CRL silently dropped, so its revocations are ignored. The merge runs each copy through AddCRL_EntryLocked. There, CompareCRLnumber sees two empty crlNumber strings as MP_EQ and returns DUPE_ENTRY_E, which src/crl.c:1982-1983 turns into success. Fix: when either side has crlNumberSet == 0, order the two CRLs by thisUpdate (lastDate) rather than treating them as equal. At minimum, do not report WOLFSSL_SUCCESS when the only incoming entry was dropped.

Why this was flagged

An app adds a CRL without the CRL Number extension (a v1 CRL, or one made with the wolfSSL_X509_CRL_* generation APIs without a number) to an X509_STORE. Later it adds a newer CRL from the same issuer and key, also with no number, through wolfSSL_X509_STORE_add_crl. The merge loop at src/crl.c:1979 calls AddCRL_EntryLocked. At src/crl.c:1066, CompareCRLnumber reads both empty crlNumber strings as 0 with mp_read_radix and returns MP_EQ, so it returns DUPE_ENTRY_E. At src/crl.c:1982-1983 that is freed and mapped to ret = 0, so the call returns WOLFSSL_SUCCESS but the store keeps only the old CRL. Certs revoked in the new CRL are then accepted, and once the old CRL's nextUpdate passes, handshakes fail with CRL_CERT_DATE_ERR. On the base branch the new entries were appended to the list, so CheckCertCRLList also read the newer CRL and found those revocations.

Verification: When there is no CRL number, crlNumber is never filled (crl.c:215-217). Both numbers read as 0, mp_cmp returns MP_EQ, and the newer CRL is dropped. The base appended the copied list to the tail (*tail = toAdd;), so the newer CRL's revocations were honored. The caller gets WOLFSSL_SUCCESS (src/crl.c ~1971-1985) and has no sign that anything was dropped.

Comment thread src/crl.c
Comment on lines +1885 to +1893
if (ent->verified == 0 && crl->cm != NULL) {
/* ent is a private copy and crl->cm owns crl, so the result can
* be cached on it. */
ret = VerifyCRLE(crl, ent, crl->cm, 1);
if (ret == WC_NO_ERR_TRACE(ASN_CRL_NO_SIGNER_E)) {
ret = 0;
}
else if (ret != 0) {
WOLFSSL_MSG("CRL failed to verify against the store's CAs");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 Loading a multi-CRL file now stops at the first CRL that fails its signature check, so later CRLs, including other issuers', are never loaded. X509StoreCheckCRLCopies (src/crl.c:1892) makes wolfSSL_X509_STORE_add_crl return WOLFSSL_FAILURE. wolfSSL_X509_load_crl_file then breaks its PEM loop (src/x509.c:10214, src/x509.c:10274). Fix: have the loaders skip a CRL whose add fails and keep reading the rest of the file. LoadCertByIssuer needs the same change for later .rN files (src/internal.c:18044). The base branch added every CRL and verified each one only when it was used.

Why this was flagged

An app loads a PEM bundle of CRLs with wolfSSL_X509_load_crl_file, or the hash directory through LoadCertByIssuer. One CRL near the front fails VerifyCRLE against the store's CAs. That gives ASN_CRL_CONFIRM_E, and X509StoreCheckCRLCopies returns it (src/crl.c:1888-1893). add_crl returns WOLFSSL_FAILURE and the loop at src/x509.c:10212-10214 breaks. The function returns the count loaded so far, so the caller sees a positive success. Every CRL after it is never added, so certs from those unrelated issuers get CRL_MISSING. If the failing CRL is the first one, the store's CRL is never created and wolfSSL_CertManagerEnableCRL(WOLFSSL_CRL_CHECKALL) never runs (src/crl.c:1931-1936). On base, add_crl failed only on alloc or lock errors, so every CRL was added and only the bad CRL's issuer was affected.

Verification: X509StoreCheckCRLCopies (src/crl.c:1885-1894) calls VerifyCRLE(crl, ent, crl->cm, 1) and swallows only ASN_CRL_NO_SIGNER_E. add_crl then returns WOLFSSL_FAILURE (src/crl.c:1930-1933). wolfSSL_X509_load_crl_file hits break at src/x509.c:10212-10214 and 10272-10274, so every later CRL in the file is never read. On the base, add_crl only appended, so the whole bundle loaded.

@aidankeefe2022 aidankeefe2022 changed the title Crl Processing Changes: Allow for multiple CRLs per issuer and allow more paths to revoke certs Crl Processing Changes: Allow for multiple CRLs per issuer Nov 17, 2026
@philljj
philljj requested a review from Frauschi November 17, 2026 21:09
@aidankeefe2022
aidankeefe2022 marked this pull request as draft November 17, 2026 21:09
@philljj
philljj requested a review from SparkiDev November 17, 2026 21:13
@aidankeefe2022

Copy link
Copy Markdown
Member Author

Decided to go in another direction new change is here #12165

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.

3 participants