Allow binding to OpenSSL 4 from portable builds#125687
Allow binding to OpenSSL 4 from portable builds#125687bartonjs wants to merge 5 commits intodotnet:mainfrom
Conversation
|
Tagging subscribers to this area: @bartonjs, @vcsjones, @dotnet/area-system-security |
There was a problem hiding this comment.
Pull request overview
This PR updates the native OpenSSL shim and X509 stack creation logic to enable portable builds to bind against OpenSSL 4 (while still preferring earlier versions when available).
Changes:
- Probe
libssl.so.4in the distro-agnostic OpenSSL loader as a fallback when 3.x/1.1 aren’t found. - Route X509 stack allocations in
pal_x509.cthroughCryptoNative_NewX509Stack()to support OpenSSL 4 thunk behavior. - Add portable-build logic in
CryptoNative_NewX509Stack()to set OpenSSL 4 stack thunks when available.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/native/libs/System.Security.Cryptography.Native/pal_x509.c | Switches temporary X509 stack creation to CryptoNative_NewX509Stack() and includes openssl.h for the prototype. |
| src/native/libs/System.Security.Cryptography.Native/opensslshim.h | Removes the shim’s type-safe sk_X509_new_null() macro now that callers are moved off it. |
| src/native/libs/System.Security.Cryptography.Native/opensslshim.c | Adds runtime probing for libssl.so.4 after attempts for 3.x and 1.1. |
| src/native/libs/System.Security.Cryptography.Native/openssl.c | Adds portable-build thunk setup for X509 stacks via OPENSSL_sk_set_thunks when present. |
src/native/libs/System.Security.Cryptography.Native/opensslshim.c
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR updates System.Security.Cryptography.Native’s OpenSSL shims to allow portable builds (distro-agnostic SSL) to successfully bind to OpenSSL 4 at runtime, and adjusts X509 stack creation so it can interoperate with OpenSSL 4’s stack free callback/thunking behavior.
Changes:
- Probe
libssl.so.4in the portable OpenSSL loader (after 3.x and 1.1.x). - Route X509 stack allocations in
pal_x509.cthroughCryptoNative_NewX509Stack()instead of directsk_X509_new_null(). - In portable builds, configure newly-created OpenSSL stacks with
OPENSSL_sk_set_thunkswhen available (to support OpenSSL 4).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/native/libs/System.Security.Cryptography.Native/pal_x509.c | Switches internal X509 stack allocations to CryptoNative_NewX509Stack() and includes openssl.h for the declaration. |
| src/native/libs/System.Security.Cryptography.Native/opensslshim.h | Removes the local type-safe sk_X509_new_null() shim macro (callers moved to CryptoNative_NewX509Stack()). |
| src/native/libs/System.Security.Cryptography.Native/opensslshim.c | Extends runtime probing to try loading libssl.so.4 when 3.x and 1.1.x are not found. |
| src/native/libs/System.Security.Cryptography.Native/openssl.c | Updates CryptoNative_NewX509Stack() to use OPENSSL_sk_new_null() and (when present) OPENSSL_sk_set_thunks in portable builds. |
vcsjones
left a comment
There was a problem hiding this comment.
Green run against OpenSSL 4.0 alpha1
No description provided.