Skip to content

improve error handling in OpenSSL init code - #125324

Merged
wfurt merged 1 commit into
dotnet:mainfrom
wfurt:osslInit2
Mar 24, 2026
Merged

wfurt merged 1 commit into
dotnet:mainfrom
wfurt:osslInit2

Conversation

@wfurt

@wfurt wfurt commented Mar 9, 2026

Copy link
Copy Markdown
Member

contributes to #122303. I don't have smoking gone. This was suggested by copilot and it looks reasonable to em. After analyzing the core dump, it claims it comes from JIT-compiled stub.

@wfurt wfurt self-assigned this Mar 9, 2026
Copilot AI review requested due to automatic review settings March 9, 2026 10:23
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

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 adjusts the native OpenSSL initialization and SSL context creation paths in System.Security.Cryptography.Native to reduce the chance of hard failures (e.g., segfaults) when OpenSSL configuration/initialization is problematic, aligning with the investigation in #122303.

Changes:

  • Add a fallback OPENSSL_init_ssl attempt without OPENSSL_INIT_LOAD_CONFIG when initialization with config loading fails.
  • Make CryptoNative_SslCtxCreate explicitly handle a null SSL_METHOD* input (returning NULL instead of passing it to SSL_CTX_new).
  • Remove the debug assert on TLS_method() return value in CryptoNative_SslV2_3Method.

Reviewed changes

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

File Description
src/native/libs/System.Security.Cryptography.Native/pal_ssl.c Adds a guard for null SSL_METHOD* in SSL context creation to avoid invalid calls into OpenSSL.
src/native/libs/System.Security.Cryptography.Native/openssl.c Adds checked initialization and a retry path to reduce fragility when OpenSSL config loading fails.

You can also share your feedback on Copilot code review. Take the survey.

@rzikm
rzikm requested a review from a team March 17, 2026 16:27

@rzikm rzikm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM with some suggestions

@wfurt
wfurt merged commit 53928dd into dotnet:main Mar 24, 2026
114 checks passed
@wfurt
wfurt deleted the osslInit2 branch March 24, 2026 15:57
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 24, 2026
@bartonjs bartonjs added the cryptographic-docs-impact Issues impacting cryptographic docs. Cleared and reused after documentation is updated each release. label Sep 11, 2026
@bartonjs bartonjs added the tracking This issue is tracking the completion of other related issues. label Oct 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Net.Security cryptographic-docs-impact Issues impacting cryptographic docs. Cleared and reused after documentation is updated each release. tracking This issue is tracking the completion of other related issues.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants