Skip to content

Conversation

rzikm
Copy link
Member

@rzikm rzikm commented Jul 14, 2025

Follow-up on #117472, now that we have managed implementation of X509 name check, we can get rid of the code which was originally bound to SslContext. This PR unifies certificate validation code between SslStream and QuicConnection.

@Copilot Copilot AI review requested due to automatic review settings July 14, 2025 15:26
@rzikm rzikm changed the title Unify certificate validation code on OSX Unify certificate validation code on OSX between SslStream and QuicConnection Jul 14, 2025
Copy link
Contributor

@Copilot 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

This PR removes the legacy macOS-specific hostname‐matching code paths and redirects certificate validation on OSX to the shared BuildChainAndVerifyProperties logic.

  • Removes AppleCryptoNative_SslIsHostnameMatch implementation and related P/Invoke/entrypoint.
  • Refactors CertificateValidationPal.OSX.VerifyCertificateProperties to call the unified validator.
  • Adds common validation helper file and updates the project to include it.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/native/libs/System.Security.Cryptography.Native.Apple/pal_ssl.h Dropped the old hostname-matching export.
src/native/libs/System.Security.Cryptography.Native.Apple/pal_ssl.c Removed the entire SslIsHostnameMatch implementation.
src/native/libs/System.Security.Cryptography.Native.Apple/entrypoints.c Deleted the DllImport entry for hostname matching.
src/libraries/System.Net.Security/src/System/Net/CertificateValidationPal.OSX.cs Replaced platform code with call to BuildChainAndVerifyProperties.
src/libraries/System.Net.Security/src/System.Net.Security.csproj Added new common validation source for OSX.
src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Ssl.cs Removed IDN mapping and hostname-check P/Invoke shim.
Comments suppressed due to low confidence (2)

src/libraries/System.Net.Security/src/System/Net/CertificateValidationPal.OSX.cs:8

  • [nitpick] Consider using a file-scoped namespace declaration (e.g., namespace System.Net;) to align with project conventions and reduce indentation.
namespace System.Net

src/libraries/System.Net.Security/src/System/Net/CertificateValidationPal.OSX.cs:20

  • Add unit tests covering the unified certificate validation logic on macOS—particularly hostname matching and chain validation—to verify parity with the previous implementation.
            return CertificateValidation.BuildChainAndVerifyProperties(chain, remoteCertificate, checkCertName, isServer, hostName, Span<byte>.Empty);

Copy link
Contributor

Tagging subscribers to this area: @dotnet/ncl, @bartonjs, @vcsjones
See info in area-owners.md if you want to be subscribed.

@liveans
Copy link
Member

liveans commented Jul 14, 2025

Seems like this is affecting some test cases: OSX Tests

Copy link
Member

@liveans liveans left a comment

Choose a reason for hiding this comment

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

LGTM. I think this will simplify changes we made in NW PR?

Copy link
Member

@wfurt wfurt left a comment

Choose a reason for hiding this comment

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

nice. lot of deletes. I hope the more code works properly :)

@rzikm
Copy link
Member Author

rzikm commented Jul 16, 2025

/ba-g infrastructure faliures are unrelated

@rzikm rzikm merged commit 5d86589 into dotnet:main Jul 16, 2025
96 of 101 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Aug 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants