Conversation
|
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. |
Contributor
|
Tagging subscribers to this area: @dotnet/ncl, @bartonjs, @vcsjones |
This was referenced Oct 27, 2026
Avoid recursive SSLEngine entry during certificate validation and map saved managed failures to terminal handshake status while draining pending alert output. Expand Android regression coverage for accepting, rejecting, and throwing callbacks. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d827a5f4-206f-4b85-8331-dfc0b820aa28
simonrozsival
force-pushed
the
simonrozsival-android-tls-rejection-fix
branch
from
November 27, 2026 13:53
0c78a65 to
49ff100
Compare
simonrozsival
marked this pull request as ready for review
November 27, 2026 15:39
Member
Author
|
/azp run runtime-android |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
This was referenced Nov 27, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
49ff100abdd6dcc9ae81434e3dea9ffc1f80ff17↑ Independent networking review found no blockers and verified exception identity, alert draining, and fallback validation.
↓ Several CI jobs on this revision are still in progress, emulator tests have not been re-run on this exact post-rebase commit, and the pushed tests do not yet isolate peer-alert delivery or
InnerException == nullon callbackfalse.CertValidationInCallback = false, and reproduced API 29 returningNeedDataafter changing only that flag.↑ Traced both failure modes directly through
SslStream.Protocol.cs,SslStreamPal.Android.cs, andSslStream.IO.cs.↓ Exact affected Android version/vendor provider boundaries beyond tested stock ARM64 emulator images are not exhaustively mapped.
SslStreamrejection timeouts across TLS 1.2 / OS-default and client/server roles, plus the coupled API 29 wait state.↓ Identified via managed emulator testing rather than a production incident trace or released-version bisection.
Summary
Fix Android
SslStreamcertificate-rejection handling so a managed validation failure terminates authentication instead of waiting for more handshake data.Follow-up to #136517 (now merged into
main). This PR is rebased ontomainand contains only the Android PAL rejection fix and the expanded Android regression theory.Platforms and scenarios
These observations come from managed
SslStreamtests on stock Android ARM64 emulator images, not just Java probes. "Without this fix" below means #136517 is present, but neither rejection-handling change in this PR is applied.falsecases timed out after 30 seconds instead of throwingAuthenticationException(TLS 1.2 / OS default, client validating server / server validating client). Existing hostname/policy rejection cases also timed out.CertValidationInCallbacktotrue, the provider emitted a fatalcertificate_unknownalert to the peer while the local PAL returnedNeedData; local authentication continued waiting.false/ throwing-callback combination. Passing with the patch does not prove a platform was affected before it.The relevant triggers are a validation callback returning
false, a callback throwing, or managed rejection of a hostname/certificate-policy error. Accepting callbacks are controls. The exact affected Android-version/provider range has not been established; passing across APIs 24–37 is not a claim that all those versions require the fix.Mechanics
Android's trust manager invokes managed certificate validation from inside
SSLEngine. MarkingCertValidationInCallback = trueprevents the managed rejection path from recursively enteringGenerateToken/ the handshake to construct a fatal alert.After the native handshake returns, the PAL gives a saved callback exception priority and returns
InternalError, preserving the original exception as theAuthenticationException.InnerException. A recorded negative validation result instead maps toCertValidationFailedwithSslStream.CreateCertificateValidationException(...). Neither can be mistaken for a request for more data.CanGenerateCustomAlertsremainstrue; it does not enable recursive managed alert generation because that path also requires!CertValidationInCallback.SSLEnginegenerates its rejection alert, andHandshakeInternalstill drains pending writes before returning the failure token so the outer handshake can send that output before throwing.The expanded theory in
AndroidPlatformTrustTestscovers acceptance, rejection (false), and throwing callbacks in both client and server validation roles, checks callback counts, preserves thrown-exception identity, and verifies negotiated connection properties and bidirectional data exchange on successful connections.Validation
Current PR revision (
49ff100abdd, rebased onmain)arm/arm64/x64AllSubsets_CoreCLR_Smokebuilds, Linux/WASM/WASI builds, andruntime-dev-innerloopanalyzer/Source-Build legs.Pre-rebase local verification of this exact two-file diff (before rebase onto
main)./build.sh clr+libs -rc release./dotnet.sh build src/libraries/System.Net.Security/src/System.Net.Security.csproj./dotnet.sh build /t:Test src/libraries/System.Net.Security/tests/FunctionalTests/System.Net.Security.Tests.csprojAndroidPlatformTrustTestssuite, API 24Total pre-rebase Android CoreCLR verification for this exact diff: 93/93 passed, including all 42 accept/
false/throw theory cases and the existing hostname/policy rejection tests on each image (TLS 1.2 and OS-default on all three; explicit TLS 1.3 added on API 29).Additional historical pre-split runs (before Mono product builds were retired): 151/151 Mono passes across APIs 24, 26, 27, 28, 29 and 920/920 combined CoreCLR/Mono passes across APIs 24–37 (444 expanded theory cases). These are historical evidence only, not fresh post-rebase runs or proof of the original affected-version range.
Scope and limits
Only Android product code and Android-specific tests change. There are no public API additions or native interop changes, and desktop behavior is not intentionally changed. Local emulator coverage is ARM64 CoreCLR (plus historical Mono), not NativeAOT, other Android architectures, physical devices, or all vendor TLS providers. No production incident, released-version bisection, or certificate-validation bypass was established.
This restores the expected failure contract so rejected authentication completes with
AuthenticationExceptionrather than hanging; no certificate-validation opt-out is added.Note
This pull request and its description were prepared with GitHub Copilot.