Registry Mirror
Skip to content

Conversation

@simonrozsival

@simonrozsival simonrozsival commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 49ff100abdd6dcc9ae81434e3dea9ffc1f80ff17

Dimension Assessment Rationale
Change confidence 8.5/10 ↑ Exact two-file fix passed 93/93 on Android APIs 24/28/29 (CoreCLR) and 5,048 desktop tests before rebase, and Android arm/arm64/x64 CoreCLR smoke CI passed on this revision.
↑ 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 == null on callback false.
Diagnosis confidence 9/10 ↑ Reproduced 30s timeouts on Android API 24 (CoreCLR and historical Mono) with CertValidationInCallback = false, and reproduced API 29 returning NeedData after changing only that flag.
↑ Traced both failure modes directly through SslStream.Protocol.cs, SslStreamPal.Android.cs, and SslStream.IO.cs.
↓ Exact affected Android version/vendor provider boundaries beyond tested stock ARM64 emulator images are not exhaustively mapped.
Evidence fit 9/10 ↑ Directly explains the observed API 24 SslStream rejection 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 SslStream certificate-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 onto main and contains only the Android PAL rejection fix and the expanded Android regression theory.

Platforms and scenarios

These observations come from managed SslStream tests 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.

Platform / configuration Scenario and observation What the evidence establishes
Android 7.0 / API 24, CoreCLR With a trusted chain, all four accepting controls passed, but all four callback-false cases timed out after 30 seconds instead of throwing AuthenticationException (TLS 1.2 / OS default, client validating server / server validating client). Existing hostname/policy rejection cases also timed out. A demonstrated rejection failure without this fix, not a general connection-info or successful-handshake failure.
Android 7.0 / API 24, Mono (pre-retirement) A separate #136517-only survey reproduced both existing wrong-hostname and wrong-policy rejection timeouts. The full module subsequently hit the 600-second harness timeout, so there is no completed-suite count for that failing run. The original rejection bug was runtime-independent on Android, not CoreCLR-only.
Android 9 / API 28 #136517-only full trust suites passed 21/21. The complete fix also passes the expanded cases. A control platform, not evidence that every older Android version originally failed.
Android 10 / API 29 #136517-only existing rejection controls pass. After changing only CertValidationInCallback to true, the provider emitted a fatal certificate_unknown alert to the peer while the local PAL returned NeedData; local authentication continued waiting. The explicit failure-status mapping is coupled regression prevention for the callback-flag correction, not evidence that untouched API 29 fails those existing controls.
Newer Android controls #136517-only full existing trust suites passed on CoreCLR APIs 29, 34, 35, 36, 37 (115/115 total) and pre-retirement Mono APIs 29, 36 (46/46 total), including hostname/policy rejection cases. These controls do not pre-fix-test every newly added trusted-chain callback-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. Marking CertValidationInCallback = true prevents the managed rejection path from recursively entering GenerateToken / 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 the AuthenticationException.InnerException. A recorded negative validation result instead maps to CertValidationFailed with SslStream.CreateCertificateValidationException(...). Neither can be mistaken for a request for more data.

CanGenerateCustomAlerts remains true; it does not enable recursive managed alert generation because that path also requires !CertValidationInCallback. SSLEngine generates its rejection alert, and HandshakeInternal still drains pending writes before returning the failure token so the outer handshake can send that output before throwing.

The expanded theory in AndroidPlatformTrustTests covers 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 on main)

  • CI checks passing at update time: Android arm / arm64 / x64 AllSubsets_CoreCLR_Smoke builds, Linux/WASM/WASI builds, and runtime-dev-innerloop analyzer/Source-Build legs.
  • Remaining macOS, iOS, MacCatalyst, Windows, Helix, and linker CI legs are still in progress.

Pre-rebase local verification of this exact two-file diff (before rebase onto main)

Check Result
Clean desktop baseline: ./build.sh clr+libs -rc release Passed
All product TFMs: ./dotnet.sh build src/libraries/System.Net.Security/src/System.Net.Security.csproj Passed, 0 warnings/errors
Desktop functional suite: ./dotnet.sh build /t:Test src/libraries/System.Net.Security/tests/FunctionalTests/System.Net.Security.Tests.csproj 5,048 passed, 31 existing skips, 0 failures
Android ARM64 CoreCLR full AndroidPlatformTrustTests suite, API 24 29/29 passed
Same full suite, API 28 29/29 passed
Same full suite, API 29 35/35 passed

Total 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 AuthenticationException rather than hanging; no certificate-validation opt-out is added.

Note

This pull request and its description were prepared with GitHub Copilot.

@azure-pipelines

azure-pipelines Bot commented Oct 27, 2026 •

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.

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
simonrozsival force-pushed the simonrozsival-android-tls-rejection-fix branch from 0c78a65 to 49ff100 Compare November 27, 2026 13:53
@simonrozsival
simonrozsival marked this pull request as ready for review November 27, 2026 15:39
@simonrozsival

Copy link
Copy Markdown
Member Author

/azp run runtime-android

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

This branch has not been deployed

No deployments
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.

1 participant