Skip to content

Avoid array allocations in GetRequestCertificateAuthorities#123904

Merged
stephentoub merged 1 commit intodotnet:mainfrom
stephentoub:getcertsalloc
Feb 3, 2026
Merged

Avoid array allocations in GetRequestCertificateAuthorities#123904
stephentoub merged 1 commit intodotnet:mainfrom
stephentoub:getcertsalloc

Conversation

@stephentoub
Copy link
Member

No description provided.

@dotnet-policy-service
Copy link
Contributor

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

Copy link
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

This PR optimizes the GetRequestCertificateAuthorities method on Windows and macOS platforms by eliminating unnecessary array allocations when processing certificate authority distinguished names.

Changes:

  • Replaced array allocation with direct ReadOnlySpan<byte> usage on both platforms
  • On macOS, replaced CFGetData() with CFDataDangerousGetSpan() using proper reference counting

Reviewed changes

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

File Description
src/libraries/System.Net.Security/src/System/Net/CertificateValidationPal.Windows.cs Changed from ToArray() to direct ReadOnlySpan<byte> usage to avoid array allocation
src/libraries/System.Net.Security/src/System/Net/CertificateValidationPal.OSX.cs Replaced CFGetData() with CFDataDangerousGetSpan() and manual reference counting to avoid array allocation

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.

LGTM

@stephentoub
Copy link
Member Author

/ba-g timeouts

@stephentoub stephentoub merged commit 3629e69 into dotnet:main Feb 3, 2026
87 of 98 checks passed
@stephentoub stephentoub deleted the getcertsalloc branch February 3, 2026 02:31
lewing pushed a commit to lewing/runtime that referenced this pull request Feb 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants