Skip to content

Remove unused OpenSSL Interop - #131968

Open
vcsjones wants to merge 2 commits into
mainfrom
vcsjones/remove-unused-crypto-native-interop
Open

Remove unused OpenSSL Interop#131968
vcsjones wants to merge 2 commits into
mainfrom
vcsjones/remove-unused-crypto-native-interop

Conversation

@vcsjones

@vcsjones vcsjones commented Aug 6, 2026

Copy link
Copy Markdown
Member

There are a few interop methods and p/invoke helpers that are no longer used. Let's delete all of them.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 0cb4b5e8-0d6f-4dc1-91ad-2cfb4fce64c8
Copilot AI lite review requested due to automatic review settings August 6, 2026 21:07
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

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.

Pull request overview

This PR removes unused OpenSSL interop exports from System.Security.Cryptography.Native and deletes corresponding managed LibraryImport declarations, reducing native surface area and dead code in the Unix crypto PAL.

Changes:

  • Removed unused native shims/exports (CryptoNative_X509Duplicate, CryptoNative_SetCiphers, CryptoNative_BioCtrlPending, CryptoNative_BigNumFromBinary) and their header declarations.
  • Updated the native export resolver table (entrypoints.c) to drop the removed entrypoints.
  • Removed unused managed LibraryImport overloads and updated the BIGNUM export to use a Span-based signature.
Show a summary per file
File Description
src/native/libs/System.Security.Cryptography.Native/pal_x509.h Removes CryptoNative_X509Duplicate declaration from the X509 PAL header.
src/native/libs/System.Security.Cryptography.Native/pal_x509.c Removes the CryptoNative_X509Duplicate implementation.
src/native/libs/System.Security.Cryptography.Native/pal_ssl.h Removes CryptoNative_SetCiphers declaration from the SSL PAL header.
src/native/libs/System.Security.Cryptography.Native/pal_ssl.c Removes the CryptoNative_SetCiphers implementation.
src/native/libs/System.Security.Cryptography.Native/pal_bio.h Removes CryptoNative_BioCtrlPending declaration from the BIO PAL header.
src/native/libs/System.Security.Cryptography.Native/pal_bio.c Removes the CryptoNative_BioCtrlPending implementation.
src/native/libs/System.Security.Cryptography.Native/pal_bignum.h Removes CryptoNative_BigNumFromBinary declaration from the BIGNUM PAL header.
src/native/libs/System.Security.Cryptography.Native/pal_bignum.c Removes the CryptoNative_BigNumFromBinary implementation.
src/native/libs/System.Security.Cryptography.Native/entrypoints.c Drops removed exports from the DllImport resolver table.
src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.X509.cs Removes unused DecodeX509(IntPtr, ...) and X509Duplicate imports.
src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Ssl.cs Removes unused overload imports and SslSetCiphers.
src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.SetProtocolOptions.cs Removes unused SslCtxSetProtocolOptions(IntPtr, ...) import.
src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.BIO.cs Removes unused BioRead/BioCtrlPending imports.
src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Bignum.cs Removes unused BigNumFromBinary + helper and switches BigNumToBinary to Span-based import.

Copilot's findings

  • Files reviewed: 14/14 changed files
  • Comments generated: 2

Comment thread src/native/libs/System.Security.Cryptography.Native/pal_x509.h
Copilot AI review requested due to automatic review settings August 11, 2026 16:05

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.

Review details

Suppressed comments (1)

src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.X509.cs:55

  • X509Duplicate has been removed from the OpenSSL interop surface, but there is still a comment in src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/OpenSslX509CertificateReader.cs (around CopyWithPrivateKey, lines ~643-644) that says "This could be X509Duplicate". Please update that comment to avoid referring to a deleted symbol (e.g., mention a "full clone via X509_dup" instead).
        /// <summary>
        /// Increment the native reference count of the certificate to protect against
        /// a free from another pointer-holder.
        /// </summary>
        [LibraryImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_X509UpRef")]
        internal static partial SafeX509Handle X509UpRef(IntPtr handle);

  • Files reviewed: 14/14 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@vcsjones
vcsjones enabled auto-merge (squash) August 11, 2026 19:16
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.

3 participants