Skip to content

Fix for peer cert verify with IP address#10169

Open
embhorn wants to merge 3 commits intowolfSSL:masterfrom
embhorn:zd21565
Open

Fix for peer cert verify with IP address#10169
embhorn wants to merge 3 commits intowolfSSL:masterfrom
embhorn:zd21565

Conversation

@embhorn
Copy link
Copy Markdown
Member

@embhorn embhorn commented Apr 8, 2026

Description

Issue with checking SAN with IP certs

Fixes zd21565

Testing

Added test cases to test_wolfSSL_X509_check_ip_asc

Checklist

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

@embhorn embhorn self-assigned this Apr 8, 2026
Copilot AI review requested due to automatic review settings April 8, 2026 20:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Fixes incorrect peer certificate verification behavior when the reference identity is an IP address by ensuring CN fallback is not used for IP checks (RFC 6125), and adds regression tests covering CN-only IP-like subjects.

Changes:

  • Skip Subject CN fallback during hostname verification when the input is an IP address.
  • Add regression tests ensuring CN-only certificates (including wildcard CN) are not accepted for IP verification.
  • Add a sanity check ensuring CN-based matching still works for non-IP hostname verification.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
tests/api/test_ossl_x509.c Adds regression tests for IP verification behavior when SAN is missing and CN looks like an IP/wildcard IP.
src/internal.c Updates hostname verification to avoid CN fallback when verifying IP addresses (RFC 6125 compliance).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

@dgarske dgarske left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐺 Skoll Code Review

Overall recommendation: APPROVE
Findings: 1 total — 1 posted, 0 skipped

Posted findings

  • [Medium] No IPv6 regression test for IP-in-CN bypasstests/api/test_ossl_x509.c:1063-1223

Review generated by Skoll via openclaw

ExpectIntEQ(wolfSSL_X509_check_ip_asc(NULL, "0.0.0.0", 0), 0);
ExpectIntEQ(wolfSSL_X509_check_ip_asc(empty, "127.128.0.255", 0), 0);

/* Regression test: a certificate with CN=<ip> and no SAN extension
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.

🟡 [Medium] No IPv6 regression test for IP-in-CN bypass
💡 SUGGEST test

The regression tests cover IPv4 addresses (CN=127.0.0.1, CN=*.0.0.1) but do not include an IPv6 test case. The fix in CheckHostName applies to all IP verification equally (the isIP flag is set by CheckIPAddr regardless of address family), so functionally the fix covers IPv6. However, adding a cert with CN=::1 (or similar IPv6 literal) and verifying it is rejected by wolfSSL_X509_check_ip_asc would strengthen the regression coverage and ensure the isIP path works for both address families. Since the underlying code fix is address-family-agnostic, this is a coverage improvement rather than a blocker.

Suggestion:

Suggested change
/* Regression test: a certificate with CN=<ip> and no SAN extension
Consider adding a test certificate with CN="::1" (no SAN) and verifying:
ExpectIntEQ(wolfSSL_X509_check_ip_asc(cn_ipv6, "::1", 0), 0);

— Skoll automated review via openclaw

@douzzer douzzer mentioned this pull request Apr 9, 2026
@ColtonWilley
Copy link
Copy Markdown
Contributor

Jenkins retest this please

Copilot AI review requested due to automatic review settings April 10, 2026 18:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 7 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

5 participants