Skip to content

[release/11.0] Fix PHA-not-offered check in NegotiateClientCertificateAsync on OpenSSL 1.1 - #136279

Merged
svick merged 1 commit into
release/11.0from
backport/pr-134641-to-release/11.0
Nov 5, 2026
Merged

svick merged 1 commit into
release/11.0from
backport/pr-134641-to-release/11.0

Conversation

@github-actions

@github-actions github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Backport of #134641 to release/11.0

/cc @rzikm @caraioniurie47

Customer Impact

#128942 removed unexpected exception in a corner case, but the fix worked only when running with OpenSSL 3+ (what we run in CI). When running on systems with OpenSSL 1.1.1, the unexpected exception still surfaced.

Regression

No, we changed the behavior in 11.0 via #128942 to not throw to avoid cryptic exceptions.

Testing

CI verifies that OpenSSL 3+ is unaffected, OpenSSL 1.1.1 tested manually.

Risk

Low, change is small and contained.

…nSSL 1.1 (#134641)

`SslRenegotiate` recognizes a TLS 1.3 client that didn't offer
post-handshake authentication by masking the OpenSSL error code with
`0X7FFFFF` (#128942). That extracts the reason only in OpenSSL 3's
layout, `lib << 23 | reason`. OpenSSL 1.1 packs `lib << 24 | func << 12
| reason`, so on 1.1.1 the error (`0x14268117`) isn't recognized and
`NegotiateClientCertificateAsync` throws `OpenSslCryptographicException`
instead of returning.

**Change.** `GetSslLibraryReason` decodes the code with the layout of
the loaded OpenSSL (`OpenSslVersionNumber() >= 0x3_00_00_00_0`, the
threshold `OpenSslX509ChainProcessor.GetVersionLookup` uses) and returns
the reason only for errors from `ERR_LIB_SSL`. An OpenSSL 3 system error
has the top bit set and fails that check. Only a
`CryptographicException`'s `HResult` is decoded, so an `IOException`
carrying an errno isn't read as an OpenSSL code.
`TlsSession.RequestClientCertificate` on a socket-bound session reads
the same status, so on 1.1.1 it now returns `Complete` instead of
throwing `AuthenticationException`, as it already did on OpenSSL 3. On
OpenSSL 3 the only difference from before is that reasons 279 and 339
from another library no longer count as "not offered".

**Why not in the shim.** `ERR_GET_REASON`'s layout is the one of the
headers the shim is compiled against: compiled against OpenSSL 3.0.2
headers, `ERR_GET_REASON(0x14268117)` is 2523415. Doing it natively
would need the same run-time version check in C and a change to what
`CryptoNative_SslRenegotiate` returns, for this one caller.

### Tests

- New `OpenSslErrorTests.GetSslLibraryReason_UsesLayoutOfLoadedOpenSsl`
unit test: the two reasons in each layout, each layout read as the
other, reason 279 from `ERR_LIB_EVP`, and an OpenSSL 3 system error. It
takes the layout as a parameter, so both layouts are covered whichever
OpenSSL the test machine has.
- On Linux x64 (Ubuntu 22.04), with the system OpenSSL 3.0.2 and with
Ubuntu 20.04's OpenSSL 1.1.1f selected through
`DOTNET_OPENSSL_VERSION_OVERRIDE=1.1`: without the change,
`SslStream_NegotiateClientCertificateAsync_Tls13PhaNotOffered` passes on
3.0.2 and fails on 1.1.1f with `error:14268117`; with it, it passes on
both.
- New
`TlsSessionTests.SocketBoundSession_RequestClientCertificate_Tls13PhaNotOffered_Completes`
(Linux), the same scenario on a socket-bound `TlsSession`: without the
change it passes on 3.0.2 and fails on 1.1.1f with
`AuthenticationException` (inner `error:14268117`); with it, it passes
on both.
- `System.Net.Security.Tests` and `System.Net.Security.Unit.Tests` on
both OpenSSL versions, compared by test name with and without the
change: apart from the tests above, the results are identical. The
failures present with and without the change are
`NegotiateAuthenticationKerberosTest` (both versions) and NTLM tests in
`NegotiateAuthenticationTests` (1.1.1f only).

Resolves #134640

> [!NOTE]
> AI-generated, written at my direction and reviewed by me before
posting. The tests ran on a local Release build (`clr+libs -rc release
-lc release`) of `main` at 99f3a67, with and without this commit, on
Ubuntu 22.04 x64; for each full-suite run the test process's memory map
was checked to confirm which `libssl` it loaded. The `ERR_GET_REASON`
value comes from a C program compiled against the OpenSSL 3.0.2 headers.

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).
12 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.

@rzikm

rzikm commented Oct 26, 2026

Copy link
Copy Markdown
Member

/ba-g test failure is unrelated

@rzikm

rzikm commented Nov 5, 2026

Copy link
Copy Markdown
Member

Approved by Jeff Schwartz over email

@rzikm rzikm added the Servicing-approved Approved for servicing release label Nov 5, 2026
@svick
svick merged commit b9df461 into release/11.0 Nov 5, 2026
89 of 93 checks passed
@svick
svick deleted the backport/pr-134641-to-release/11.0 branch November 5, 2026 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants