Repository navigation
Fail SSL_CTRL_CHAIN when a chain certificate cannot be added - #11856
Open
ohki-saito wants to merge 2 commits into
Open
ohki-saito wants to merge 2 commits into
ohki-saito wants to merge 2 commits into
Conversation
|
Can one of the admins verify this patch? |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Failure cleanup leaves a stale chain count that can cause a TLS 1.3 crash, and the regression test needs a PEM feature guard.
2 open issues
What changed in this PR
This PR tightens error handling in wolfSSL’s OpenSSL-compatible chain setter so failed certificate additions report failure rather than leaving inconsistent chains.
Changes:
- Reject NULL certificates, failed reference increments, and failed chain additions.
- Transfer stack ownership only on success and clear chain buffers on failure.
- Add a regression test for replacing a valid chain with one containing an empty certificate.
| File | Description |
|---|---|
tests/api/test_ssl_cert.h |
Declares and registers the regression test. |
tests/api/test_ssl_cert.c |
Tests failure reporting and chain cleanup. |
src/ssl.c |
Updates SSL_CTRL_CHAIN error handling and ownership logic. |
Review effort: Balanced
Contributor
Author
|
Addressed both review comments:
|
Member
|
Okay to test |
ohki-saito
marked this pull request as ready for review
November 6, 2026 08:06
|
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
Fenrir Finding F-8873
wolfSSL_CTX_ctrl(SSL_CTRL_CHAIN)(used bySSL_CTX_set0_chain/SSL_CTX_set1_chain) only logged errors fromwolfSSL_CTX_add_extra_chain_cert()and still returned success. This leftctx->certChain(DER) andctx->x509Chain(X509) inconsistent. A failedwolfSSL_X509_up_ref()also still calledwolfSSL_CTX_add_extra_chain_cert(), which could consume the stack's own reference.Changes:
WOLFSSL_FAILUREif a certificate is NULL, its reference count cannot be increased, or it cannot be added to the chain.up_reffails, so the stack's reference is never consumed.skonly on success. On failure, free the previous chain and clear bothctx->certChainandctx->x509Chain; the caller still ownssk.Testing
Added
test_wolfSSL_CTX_set0_chain_bad_cert: sets a valid chain, then a chain containing an empty X509, and checks that the call fails and leaves bothctx->certChainandctx->x509ChainNULL.Checklist