Keep out CAs from cert manager if allowed only by callback - #11110
Open
mattia-moffa wants to merge 1 commit into
Open
Keep out CAs from cert manager if allowed only by callback#11110mattia-moffa wants to merge 1 commit into
mattia-moffa wants to merge 1 commit into
Conversation
When an application's verify callback overrides ASN_NO_SIGNER_E or ASN_SELF_SIGNED_E on a cert, DoVerifyCallback() clears ret. ProcessPeerCerts() then reads ret==0 as proof that the CA is valid and calls AddCA() to add it to the WOLFSSL_CTX certificate manager. Instead, the callback allowing a CA is meant to be a one-time exception. This fix records the real certificate verification result and skips AddCA() if the callback is what cleared a trust error. Other types of errors don't prevent AddCA() because in those cases the cert is still trusted. All of this is only relevant when WOLFSSL_ALT_CERT_CHAINS is not enabled, because the alt cert chains logic sets skipAddCA on an unverified cert before even doing the callback logic.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts certificate-chain processing so that intermediate CA certificates are not added to the WOLFSSL_CTX certificate manager when they are only accepted due to an application verify-callback overriding ASN_NO_SIGNER_E or ASN_SELF_SIGNED_E. This preserves the intended “one-time exception” semantics of the callback and prevents unintended trust persistence across connections.
Changes:
- Track the pre-callback verification result (
preCbRet) inProcessPeerCerts()before invokingDoVerifyCallback(). - When the callback clears
ASN_NO_SIGNER_E/ASN_SELF_SIGNED_Eto success, setskipAddCAso the CA is not added to the cert manager.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Member
Author
|
Jenkins retest this please |
|
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
When an application's verify callback overrides
ASN_NO_SIGNER_EorASN_SELF_SIGNED_Eon a cert,DoVerifyCallback()clearsret.ProcessPeerCerts()then readsret==0as proof that the CA is valid and callsAddCA()to add it to theWOLFSSL_CTXcertificate manager.Instead, the callback allowing a CA is meant to be a one-time exception, specific to that one peer (i.e. the CA shouldn't go to the CTX's cert manager). This fix records the real certificate verification result and skips
AddCA()if the callback is what cleared a trust error. Other types of errors don't preventAddCA()because in those cases the cert is still trusted.All of this is only relevant when
WOLFSSL_ALT_CERT_CHAINSis not enabled, because the alt cert chains logic setsskipAddCAon an unverified cert before even doing the callback logic.Fixes zd#22289
Testing