Skip to content

Check rfc822Name SANs in wolfSSL_X509_check_email() - #11928

Merged
philljj merged 3 commits into
wolfSSL:masterfrom
holtrop-wolfssl:zd22694-b
Oct 30, 2026
Merged

philljj merged 3 commits into
wolfSSL:masterfrom
holtrop-wolfssl:zd22694-b

Conversation

@holtrop-wolfssl

Copy link
Copy Markdown
Contributor

Description

wolfSSL_X509_check_email() only compared the subject emailAddress, so a certificate whose rfc822Name SAN named a different mailbox still matched on its subject, and one with a matching SAN but different subject was rejected.

Match the rfc822Name SANs first and fall back to the subject only when there are none (RFC 6125 6.4.4, as OpenSSL does). If rfc822Name SANs aren't decoded (IGNORE_NAME_CONSTRAINTS, or WOLFSSL_X509_TINY without WOLFSSL_X509_TINY_SAN_EMAIL), fail for any certificate with a SAN extension rather than trusting the subject. Handle chkLen like check_host: reject embedded NULs and drop one trailing NUL.

Add a regression test covering the SAN/subject matrix and chkLen cases.

Fixes ZD#22694 issue B.

Testing

How did you test?

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

@holtrop-wolfssl holtrop-wolfssl self-assigned this Oct 29, 2026
Copilot AI balanced review requested due to automatic review settings October 29, 2026 19:44
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

gcc-arm-cortex-m4-openssl-compat

  • FLASH: .text +128 B (+0.0%, 796,252 B / 1,048,576 B, total: 76% used)

zephyr-frdm_rw612

  • FLASH: log_const_area -8 B, rodata -8 B, text +1,600 B (+0.6%, 284,048 B / 67,108,864 B, total: 0% 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

Email SAN matching incorrectly treats domains as case-sensitive, and the new tests lack signing and RNG feature guards, causing failures in reduced-feature builds.

2 open issues
What changed in this PR

Updates wolfSSL’s OpenSSL-compatible email verification to prioritize certificate rfc822Name subject alternative names (SANs) over the subject email address.

Changes:

  • Checks email SANs first and blocks subject fallback when SAN decoding is unavailable.
  • Normalizes explicit email lengths and rejects embedded NULs.
  • Adds regression coverage for SAN/subject combinations and length handling.
File Description
tests/​api/​test_ossl_x509.h Declares and registers the new SAN regression test.
tests/​api/​test_ossl_x509.c Adds generated certificate cases and updates configuration-dependent expectations.
src/​x509.c Implements SAN-first email matching and input-length validation.

Review effort: Balanced

Comment thread src/x509.c Resolved
Comment thread tests/api/test_ossl_x509.c Resolved
wolfSSL_X509_check_email() only compared the subject emailAddress, so a
certificate whose rfc822Name SAN named a different mailbox still matched
on its subject, and one with a matching SAN but different subject was
rejected.

Match the rfc822Name SANs first and fall back to the subject only when
there are none (RFC 6125 6.4.4, as OpenSSL does). If rfc822Name SANs
aren't decoded (IGNORE_NAME_CONSTRAINTS, or WOLFSSL_X509_TINY without
WOLFSSL_X509_TINY_SAN_EMAIL), fail for any certificate with a SAN
extension rather than trusting the subject. Handle chkLen like
check_host: reject embedded NULs and drop one trailing NUL.

Add a regression test covering the SAN/subject matrix and chkLen cases.
@holtrop-wolfssl

Copy link
Copy Markdown
Contributor Author

retest this please

@philljj philljj self-assigned this Oct 30, 2026
@philljj
philljj merged commit 0b072fa into wolfSSL:master Oct 30, 2026
430 checks passed
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.

4 participants