Skip to content

[flaky-ci] Classify pre-TLS failures in trusted certificate test - #12714

Merged
simonrozsival merged 5 commits into
mainfrom
simonrozsival-trusted-certificates-test-stability
Sep 10, 2026
Merged

simonrozsival merged 5 commits into
mainfrom
simonrozsival-trusted-certificates-test-stability

Conversation

@simonrozsival

@simonrozsival simonrozsival commented Sep 8, 2026 •

Copy link
Copy Markdown
Member

Why

System.NetTests.SslTest.VerifyTrustedCertificates validates Android default/system trust against google.com, but CI failures occurred before TLS certificate validation began:

These stacks ended while constructing TcpClient, before SslStream.AuthenticateAsClient, so they do not indicate certificate expiry, rotation, device trust-store state, device time, or test ordering problems.

Fixes #12704

What changed

The test still validates google.com through Android default/system trust. The pre-TLS connection is ignored only for managed HostNotFound, NoData, NetworkUnreachable, and HostUnreachable, plus Android native ENETUNREACH and EHOSTUNREACH values when they are surfaced without managed normalization. Endpoint and socket diagnostics are retained.

TLS authentication remains outside that catch boundary, so timeouts, connection resets/refusals, authentication, hostname, expiry, chain, TLS alert, and all other failures continue to fail.

Parameterized regression coverage pins the four managed values and verifies that TimedOut and ConnectionReset remain failures. Native SocketException coverage pins ENETUNREACH and EHOSTUNREACH as ignored and ECONNRESET as non-ignored.

Testing

On emulator-5554:

  • Debug SSL category: 33 passed, 0 failed, 0 skipped; classifier coverage and VerifyTrustedCertificates passed.
  • Release TestsFlavor=NoAab, AndroidPackageFormat=apk SSL category: 33 passed, 0 failed, 0 skipped; classifier coverage and VerifyTrustedCertificates passed.

simonrozsival and others added 2 commits September 8, 2026 11:35
Keep Android system trust validation against google.com, but ignore only the approved DNS and routing failures that occur before SslStream creation. All TLS and certificate validation failures continue to fail the test.\n\nCo-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
@simonrozsival simonrozsival added the flaky-ci Intermittent CI failures and work to improve CI reliability label Sep 8, 2026
@simonrozsival

Copy link
Copy Markdown
Member Author

/review

@github-actions

github-actions Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

✅ Android PR Reviewer completed successfully!

Generated by Android PR Reviewer for #12714

@github-actions github-actions Bot 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.

⚠️ Needs Changes

Findings: 0 errors, 0 warnings, 1 suggestion.

The implementation correctly limits ignores to selected connection failures raised before SslStream.AuthenticateAsClient, preserves TLS/certificate failures as test failures, and now disposes both network resources. I left one inline suggestion to pin the deliberately narrow socket-error whitelist with parameterized coverage.

CI is currently red: dotnet-android (Package Tests macOS > Tests > APKs 1) failed in build 1586953. The available check data does not expose the underlying test/task failure, so that lane still needs investigation or a successful rerun before merge.

Generated by Android PR Reviewer for #12714 · gpt56 · 92.4 AIC · ⌖ 8.88 AIC · ⊞ 25.7K
Comment /review to run again

Comment thread tests/Mono.Android-Tests/Mono.Android-Tests/System.Net/SslTest.cs
Pin the four socket errors that may skip the external system-trust test and representative errors that must continue to fail.

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

Copy link
Copy Markdown
Member Author

/review

@github-actions

github-actions Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

✅ Android PR Reviewer completed successfully!

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • azcliprod.blob.core.windows.net

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "azcliprod.blob.core.windows.net"

See Network Configuration for more information.

Generated by Android PR Reviewer for #12714

@github-actions github-actions Bot 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.

⚠️ Needs Changes

Findings: 0 errors, 1 warning, 0 suggestions.

The change correctly separates TCP connection setup from SslStream.AuthenticateAsClient() and adds focused policy coverage. However, the new socket-error whitelist still allows other failures raised before TLS begins—such as timeouts, resets, and refused connections—to fail a certificate-validation test. I left an inline comment recommending that the phase boundary, rather than selected socket codes, determine what is ignored.

CI build 1587827 is currently red: the Linux build and macOS build checks failed, while the Windows build remains in progress. The Azure timeline/log details could not be retrieved because this runner has no Azure DevOps authentication, so I could not determine whether those build failures are caused by this PR.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • azcliprod.blob.core.windows.net

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "azcliprod.blob.core.windows.net"

See Network Configuration for more information.

Generated by Android PR Reviewer for #12714 · gpt56 · 76.8 AIC · ⌖ 8.95 AIC · ⊞ 25.7K
Comment /review to run again

Comment thread tests/Mono.Android-Tests/Mono.Android-Tests/System.Net/SslTest.cs
@simonrozsival
simonrozsival marked this pull request as ready for review September 9, 2026 21:57
Copilot AI lite review requested due to automatic review settings September 9, 2026 21:57

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.

Copilot review overview

🟢 Approval recommended

The change is scoped to test behavior, preserves TLS validation semantics, and adds regression coverage to prevent broadening the ignore allowlist unintentionally.

Review tier: Lite
Findings: 1 Low severity

New issues introduced by this change (1)
Severity Finding
Low severity tests/​Mono.Android-Tests/​Mono.Android-Tests/​System.Net/​SslTest.cs — 💡 Suggestion: google.com and 443 are duplicated across the connect path, TLS SNI/hostname, and…
What changed in this PR

This PR reduces CI noise in System.NetTests.SslTest.VerifyTrustedCertificates by distinguishing pre-TLS external connectivity failures (DNS/routing) from actual TLS/certificate-validation failures, and only ignoring the former so the test remains a trust-store validation.

Changes:

  • Split the test into an explicit TCP connect step and a separate TLS authentication step.
  • Ignore a specific allowlist of SocketError values that occur before TLS begins, emitting more diagnostic detail.
  • Add a parameterized regression test that pins which SocketError values are ignored vs. still treated as failures.
File Description
tests/​Mono.Android-Tests/​Mono.Android-Tests/​System.Net/​SslTest.cs Refactors the trusted certificate test to ignore specific pre-TLS connectivity failures and adds allowlist regression coverage.
Suppressed comments (1)

tests/Mono.Android-Tests/Mono.Android-Tests/System.Net/SslTest.cs:141

  • 💡 Suggestion: IsExternalConnectivityFailure can be simplified with pattern matching (is ... or ...), which makes the allowlist easier to scan and reduces control-flow noise.
		static bool IsExternalConnectivityFailure (SocketError socketError)
		{
			switch (socketError) {
				case SocketError.HostNotFound:
				case SocketError.NoData:
				case SocketError.NetworkUnreachable:
				case SocketError.HostUnreachable:
					return true;
			}

			return false;
		}

Comment thread tests/Mono.Android-Tests/Mono.Android-Tests/System.Net/SslTest.cs
@simonrozsival simonrozsival added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Sep 10, 2026
Android can expose ENETUNREACH and EHOSTUNREACH as raw native SocketErrorCode values. Classify those only during the pre-TLS connection while preserving all other connection and certificate failures.

Co-authored-by: Copilot App <[email protected]>
@simonrozsival
simonrozsival enabled auto-merge (squash) September 10, 2026 20:10
@simonrozsival
simonrozsival merged commit 263fe5c into main Sep 10, 2026
44 checks passed
@simonrozsival
simonrozsival deleted the simonrozsival-trusted-certificates-test-stability branch September 10, 2026 20:37
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

flaky-ci Intermittent CI failures and work to improve CI reliability ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI flakiness inventory: Aug 11-Sep 8, 2026

3 participants