Skip to content

Fix OpenSSL 4 signature configuration and renegotiation errors - #138127

Merged
rzikm merged 1 commit into
dotnet:mainfrom
rzikm:rzikm/ubuntu-tls-compatibility
Nov 24, 2026
Merged

rzikm merged 1 commit into
dotnet:mainfrom
rzikm:rzikm/ubuntu-tls-compatibility

Conversation

@rzikm

@rzikm rzikm commented Nov 23, 2026

Copy link
Copy Markdown
Member

Prioritizing OpenSSL 4 in #137823 exposed two compatibility failures in RSA-padding configuration and post-handshake client authentication. The same Ubuntu 26.10 image previously passed the affected cases with OpenSSL 3.

  • Map the advertised SM2 signature scheme (0x0708) to sm2sig_sm3. The fallback string 0x0708 is rejected by OpenSSL 4.0.3, causing signature-list configuration to fail before authentication completes. Add a four-case theory covering the RSA-padding combinations.
  • Treat failures from SSL_verify_client_post_handshake and SSL_renegotiate as error-queue failures rather than querying SSL_get_error. These APIs schedule work, rather than perform I/O. OpenSSL 4 no longer consults the error stack in SSL_get_error, so the old code could return a previous WANT_READ and lose the queued failure reason.

The PHA documentation explicitly directs callers to the error stack; the SSL_get_error documentation describes its I/O-only contract and the OpenSSL 4 change. Reporting SSL_ERROR_SSL from our shim routes the failure through existing queue decoding. The actual SSL_R_EXTENSION_NOT_RECEIVED reason and its NoRenegotiation mapping remain unchanged.

Validation

Built and tested Linux x64 in WSL using the exact CI image's OpenSSL 4.0.3 and 3.5.5 libraries, selected with LD_LIBRARY_PATH and DOTNET_OPENSSL_VERSION_OVERRIDE. Verified the loaded library versions.

Command Result
./build.sh clr+libs -rc release Passed
./dotnet.sh build src/native/libs/build-native.proj -p:RuntimeConfiguration=Release Passed
./dotnet.sh build src/libraries/System.Net.Security/src/System.Net.Security.csproj -p:RuntimeConfiguration=Release Passed
./dotnet.sh build src/libraries/System.Net.Security/tests/FunctionalTests/System.Net.Security.Tests.csproj /t:Test -p:RuntimeConfiguration=Release Both OpenSSL versions: 5,164 passed, 0 failed, 8 skipped
./dotnet.sh build src/libraries/System.Net.Security/tests/UnitTests/System.Net.Security.Unit.Tests.csproj /t:Test -p:RuntimeConfiguration=Release Both versions: 129 passed, 1 pre-existing failure, 12 skipped

All eight affected RSA/PHA cases pass on both versions. Before the fix, the new signature theory failed all four cases and both affected PHA tests failed on OpenSSL 4. All nine existing error-layout theory cases still pass.

The unit failure is NegotiateAuthenticationTests.Package_Unsupported_NTLM (expected Unsupported, actual ContinueNeeded). Rebuilt pristine source and reproduced that same failure on both OpenSSL versions: 125 passed, 1 failed, 12 skipped. No assertions were relaxed or tests disabled.

Validation used the extracted libraries, not a complete CI-container run. OpenSSL 1.x/4.1 and other platforms were not tested.

Note

These code changes and this PR description were prepared with GitHub Copilot.

Map the SM2 signature scheme advertised by OpenSSL 4 to its accepted name. Read failures from non-I/O renegotiation APIs through the error queue instead of consulting stale SSL_get_error I/O state. Add coverage for configuring all RSA-padding combinations.

Co-authored-by: Copilot App <[email protected]>
@azure-pipelines

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

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

@vcsjones

Copy link
Copy Markdown
Member

We should probably back port this to .NET 11 and .NET 10. While 11 and 10 will remain "preferring" OpenSSL 3 over 4, they do load OpenSSL 4 if 4 is the only one available.

@rzikm
rzikm merged commit e59cd98 into dotnet:main Nov 24, 2026
73 of 75 checks passed
@rzikm

rzikm commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

/backport to release/11.0

@rzikm

rzikm commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

/backport to release/10.0

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/11.0 (link to workflow run)

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/10.0 (link to workflow run)

@github-actions

Copy link
Copy Markdown
Contributor

@rzikm backporting to release/10.0 failed, the patch most likely resulted in conflicts. Please backport manually!

git am output
$ git cherry-pick e59cd983cf02cae356d135079a058a3c2b65e249

Auto-merging src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSsl.cs
CONFLICT (modify/delete): src/libraries/System.Net.Security/tests/UnitTests/OpenSslErrorTests.cs deleted in HEAD and modified in e59cd983cf0 (Fix OpenSSL 4 signature configuration and renegotiation errors (#138127)).  Version e59cd983cf0 (Fix OpenSSL 4 signature configuration and renegotiation errors (#138127)) of src/libraries/System.Net.Security/tests/UnitTests/OpenSslErrorTests.cs left in tree.
Auto-merging src/native/libs/System.Security.Cryptography.Native/pal_ssl.c
CONFLICT (content): Merge conflict in src/native/libs/System.Security.Cryptography.Native/pal_ssl.c
error: could not apply e59cd983cf0... Fix OpenSSL 4 signature configuration and renegotiation errors (#138127)
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config set advice.mergeConflict false"


$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: Fix OpenSSL 4 signature configuration and renegotiation errors
Using index info to reconstruct a base tree...
M	src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSsl.cs
A	src/libraries/System.Net.Security/tests/UnitTests/OpenSslErrorTests.cs
M	src/native/libs/System.Security.Cryptography.Native/pal_ssl.c
Falling back to patching base and 3-way merge...
Auto-merging src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSsl.cs
CONFLICT (modify/delete): src/libraries/System.Net.Security/tests/UnitTests/OpenSslErrorTests.cs deleted in HEAD and modified in Fix OpenSSL 4 signature configuration and renegotiation errors.  Version Fix OpenSSL 4 signature configuration and renegotiation errors of src/libraries/System.Net.Security/tests/UnitTests/OpenSslErrorTests.cs left in tree.
Auto-merging src/native/libs/System.Security.Cryptography.Native/pal_ssl.c
CONFLICT (content): Merge conflict in src/native/libs/System.Security.Cryptography.Native/pal_ssl.c
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 Fix OpenSSL 4 signature configuration and renegotiation errors
Error: The process '/usr/bin/git' failed with exit code 128

Link to workflow output

@github-actions

Copy link
Copy Markdown
Contributor

@rzikm backporting to release/11.0 failed, the patch most likely resulted in conflicts. Please backport manually!

git am output
$ git cherry-pick e59cd983cf02cae356d135079a058a3c2b65e249

Auto-merging src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSsl.cs
Auto-merging src/libraries/System.Net.Security/tests/UnitTests/OpenSslErrorTests.cs
CONFLICT (content): Merge conflict in src/libraries/System.Net.Security/tests/UnitTests/OpenSslErrorTests.cs
Auto-merging src/native/libs/System.Security.Cryptography.Native/pal_ssl.c
error: could not apply e59cd983cf0... Fix OpenSSL 4 signature configuration and renegotiation errors (#138127)
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config set advice.mergeConflict false"


$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: Fix OpenSSL 4 signature configuration and renegotiation errors
Using index info to reconstruct a base tree...
M	src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSsl.cs
M	src/libraries/System.Net.Security/tests/UnitTests/OpenSslErrorTests.cs
M	src/native/libs/System.Security.Cryptography.Native/pal_ssl.c
Falling back to patching base and 3-way merge...
Auto-merging src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSsl.cs
Auto-merging src/libraries/System.Net.Security/tests/UnitTests/OpenSslErrorTests.cs
CONFLICT (content): Merge conflict in src/libraries/System.Net.Security/tests/UnitTests/OpenSslErrorTests.cs
Auto-merging src/native/libs/System.Security.Cryptography.Native/pal_ssl.c
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 Fix OpenSSL 4 signature configuration and renegotiation errors
Error: The process '/usr/bin/git' failed with exit code 128

Link to workflow output

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