Repository navigation
Conversation
The CA Extended Key Usage check in ProcessPeerCerts() ran only for CA certificates in the peer's Certificate message. When the peer sent just its leaf, the issuing CA came from the CertManager and its Extended Key Usage was not looked at, so the result depended on whether the peer included the intermediate. Record in the Signer whether the certificate had an Extended Key Usage extension, and after the leaf checks walk every CA from the leaf's issuer up to the self-signed trust anchor, applying the TLS purpose to each. The walk uses the same AKID-or-name lookup as the name constraints check, which is exported as wolfssl_local_FindSignerByAkidOrName(). Trusted peer certificates are not checked, as their chain is not used. Extend test_wolfSSL_chain_ca_ext_key_usage with leaf-only cases at depth one and two for server and client authentication, verify callback handling and a self-signed trust anchor.
|
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Pending signers and restored caches can bypass issuer EKU checks, and repeated checks can invalidate certificate-specific callback overrides.
3 open issues
What changed in this PR
This PR extends TLS issuer Extended Key Usage checks to CAs loaded in the CertManager, aiming to make validation independent of which intermediates the peer sends.
Changes:
- Records EKU extension presence on cached signers.
- Walks issuer ancestors to enforce the TLS purpose while exempting self-signed trust anchors.
- Adds leaf-only chain tests for server/client authentication, callback overrides and trust-anchor handling.
| File | Description |
|---|---|
wolfssl/wolfcrypt/asn.h |
Adds signer EKU presence state and declares the shared issuer lookup. |
wolfcrypt/src/asn.c |
Populates the new state and exposes the existing ancestor lookup. |
tests/api/test_ssl_cert.c |
Extends the handshake harness and adds cached-issuer test cases. |
src/internal.c |
Adds issuer-chain EKU validation during peer certificate processing. |
Review effort: Balanced
| return EXTKEYUSE_AUTH_E; | ||
| } | ||
| #ifndef IGNORE_NAME_CONSTRAINTS | ||
| parent = wolfssl_local_FindSignerByAkidOrName(SSL_CM(ssl), NULL, ca); |
| byte extKeyUsage; | ||
| word16 maxPathLen; | ||
| WC_BITFIELD selfSigned:1; /* Own key verified the signature */ | ||
| WC_BITFIELD extExtKeyUsageSet:1; /* EKU extension present */ |
| !args->haveTrustPeer && | ||
| #endif | ||
| !UsingChainVerifyCb(ssl)) { | ||
| ret = CheckSignerExtKeyUsage(ssl, args->dCert->ca); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Description
ProcessPeerCerts()checks the Extended Key Usage of CA certificates against the TLS purpose (serverAuthwhen verifying a server,clientAuthwhen verifying a client), but only for CAs the peer sends in its Certificate message. When the peer sends only its leaf and the issuing CA is already loaded in the CertManager, that CA's Extended Key Usage is not checked. The same chain is therefore rejected withEXTKEYUSE_AUTH_Ewhen the intermediate is sent and accepted when it is omitted.This change makes the result independent of which CAs the peer sends:
Signergains anextExtKeyUsageSetbit, set byFillSigner(), so an absent extension can be told apart from one that grants none of the known purposes.CheckSignerExtKeyUsage()walks from the leaf's issuer up to the self-signed trust anchor and applies the TLS purpose to every CA on the way. The trust anchor stays exempt, as inCheckChainCAExtKeyUsage(). The walk reuses the name constraints ancestor lookup, now exported aswolfssl_local_FindSignerByAkidOrName(), with the same cycle guard andWOLFSSL_MAX_CHAIN_DEPTHlimit.WOLFSSL_TRUST_PEER_CERT), whose chain is not used.IGNORE_NAME_CONSTRAINTStheSignerhas no issuer lookup data, so only the leaf's direct issuer is checked.Testing
test_wolfSSL_chain_ca_ext_key_usagegains aleafOnlyoption, where the peer sends only the leaf and the CAs are loaded into the verifier. New cases:codeSigningandclientAuthCA rejected, andserverAuth, no extension andanyExtendedKeyUsageaccepted, when verifying a servercodeSigningandserverAuthCA rejected, andclientAuthand no extension accepted, when verifying a clientEXTKEYUSE_AUTH_E, showing that the callback is given that errorcodeSigningtrust anchor with a leaf-only chain, which stays acceptedBuilt and run with the default configure flags plus cert generation, and with each of
OPENSSL_EXTRA,OPENSSL_EXTRA+WOLFSSL_CHAIN_VERIFY_CB,IGNORE_NAME_CONSTRAINTS,WOLFSSL_ASN_ORIGINAL,WOLFSSL_ALT_CERT_CHAINSwith CRL/OCSP and status request,WOLFSSL_TRUST_PEER_CERT, andNO_SKID. A trusted peer leaf whose issuer name matches a restricted CA in the CertManager still connects with the example client (-E). The new cases fail without the library change. The full--apisuite passes in the default andOPENSSL_EXTRAbuilds.NO_SKIDnote: the existing self-issued rollover cases in this test already fail on master withNO_SKID(ASN_SIG_CONFIRM_E); this change does not affect them.Checklist