Repository navigation
Fix wolfSSL_d2i_X509_fp's handling of multiple certs in a single DER. - #12160
kareem-wolfssl wants to merge 3 commits into
Conversation
|
@claude review |
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the change supporting sequential reads of concatenated DER certificates.
No open issues 🎉
What changed in this PR
Fixes wolfSSL_d2i_X509_fp so callers can read concatenated DER certificates one at a time, preserving the file position for subsequent reads.
Changes:
- Reads from the current file position and advances past only the decoded certificate.
- Adds and registers regression coverage for sequential certificate reads through both file and BIO APIs, including end-of-file handling.
| File | Description |
|---|---|
tests/api/test_ossl_x509_io.h |
Declares and registers the concatenated-certificate regression test. |
tests/api/test_ossl_x509_io.c |
Tests sequential file and BIO reads, certificate contents, and end-of-file behavior. |
src/x509.c |
Updates file decoding to consume one certificate from the current position. |
Review effort: Balanced
|
There was a problem hiding this comment.
Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.
Beyond the inline finding, I also checked whether removing the explicit size check from wolfSSL_d2i_X509_fp_ex loosened anything. It didn't: wolfssl_file_len still rejects sizes above MAX_WOLFSSL_FILE_SIZE and sizes of 0 or less (src/ssl_misc.c:265). I also checked whether start can be used before it is set. It can't: when wolfssl_file_len fails, sz stays 0 and the function returns before the seek.
Extended reasoning...
The change makes wolfSSL_d2i_X509_fp_ex (src/x509.c) read from the file's current position and decode only one certificate per call, using wolfssl_file_len from ssl_misc.c. That file is #included into ssl.c before x509.c, so x509.c can see the static helper.
…he file. Also support other types (CSR, CRL, PKCS12 etc).
3416938 to
33dc78a
Compare
Description
Fixes zd#22757
Testing
Provided reproducer, added test
Checklist