Repository navigation
Align Linux IP certificate name matching with Windows - #135573
Merged
Merged
Conversation
Use exact DNS SAN and CN matching without wildcards after IP SAN matching. Propagate OpenSSL matching errors and cover IPv4/IPv6 behavior with TLS regression cases. Fixes dotnet#131734 Co-authored-by: Copilot App <[email protected]> Copilot-Session: 157c8032-dde4-46fd-aacd-8aa770fdfe74
|
Azure Pipelines: Successfully started running 4 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @dotnet/ncl, @bartonjs, @vcsjones |
makazeu
marked this pull request as ready for review
October 10, 2026 12:49
bartonjs
reviewed
Nov 4, 2026
bartonjs
reviewed
Nov 4, 2026
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Use named scenarios and named arguments for the certificate matching matrix. Preserve the existing coverage and add both equivalent-IPv6-spelling DNS SAN cases. Explain validation isolation and callback behavior in the theory body. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
bartonjs
approved these changes
Nov 6, 2026
Co-authored-by: Copilot App <[email protected]>
bartonjs
approved these changes
Nov 6, 2026
bartonjs
enabled auto-merge (squash)
November 6, 2026 00:47
This was referenced Nov 6, 2026
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.
Summary
Align Linux certificate-name validation with Windows behavior when
SslStream.TargetHostis an IP address (IPv4 or IPv6), not a DNS hostname. The cross-platform tests identified three scenarios where the existing Linux and Windows results differ; this PR makes Linux follow Windows in those scenarios.cc @wfurt
Observed platform differences
The results below are from installed .NET 10.0.14 runtimes, before this fix.
192.0.2.1DNS:example.test192.0.2.1*.0.2.1or*.2.1, with no IP SAN. Windows reports a mismatch; Linux matches. The control cases support CN fallback, not wildcard-based IP matching.192.0.2.1DNS:*.0.2.1192.0.2.1other.testDNS:192.0.2.1192.0.2.1Additional IPv6 boundary checks used
CN=other.testand compared DNS SAN2001:0db8:0:0:0:0:0:1with target2001:db8::1, and the reverse. Both platforms reported a name mismatch in both directions: the tested numeric DNS SAN does not match merely because the IPv6 address bytes are equal (report rows 33-34).For the full cross-platform results, environment details, and reproduction code, see the test report in dotnet/runtime#131734.
Matchmeans noRemoteCertificateNameMismatch; certificate-chain validation is a separate check.Approach
Keep the existing byte-for-byte IP SAN check as the first and fast path. If it does not match, use OpenSSL’s
X509_check_hostfor DNS SAN/CN text matching, with wildcard expansion disabled for IP targets. This lets OpenSSL apply DNS SAN precedence while retaining the legacy CN fallback observed on Windows when there are no DNS SAN entries, including certificates with only a nonmatching IP SAN.This change targets Windows compatibility rather than RFC 9525 IP-ID matching, which requires an exact match against an
iPAddressSAN (§6.2 and §6.4) and does not permit CN fallback (§2).Changes
CryptoNative_CheckX509IpAddresswithX509_check_host.CertificateValidation.Unix.csas cryptographic errors for IP targets as well as DNS hostnames.SslStreamTLS cases covering CN-only certificates, matching and conflicting IP SANs, DNS SAN precedence, numeric DNS SANs, wildcard names, and equivalent IPv6 addresses with different DNS SAN spellings. Each case has a descriptive scenario name and named inputs; comments explain the certificate-validation setup.Validation
Built and tested in Docker on Ubuntu 24.04, Linux x64 (Release CoreCLR, Debug libraries). 0 test failures.
System.Net.SecurityfunctionalSystem.Net.SecurityunitCo-authored-by: Copilot App [email protected]
Resolves #131734
Note
This description was generated with GitHub Copilot.