Uh oh!
There was an error while loading. Please reload this page.
Use a local HTTPS server in SslTest.HttpsShouldWork - #12058
Merged
Conversation
Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>
CopilotAI
changed the title
[WIP] Fix flaky SslTest.HttpsShouldWork due to external server errorsUse a local HTTPS server in Jul 13, 2026
SslTest.HttpsShouldWorksimonrozsival
marked this pull request as ready for review
July 13, 2026 21:55
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves reliability of on-device networking tests by removing dependency on external HTTPS endpoints in SslTest.HttpsShouldWork and instead using the existing loopback LocalHttpsServer, reducing flakiness from transient internet/service failures.
Changes:
- Replace requests to
dotnet.microsoft.com/bing.comwith a request toLocalHttpsServer’s/okendpoint. - Validate the local response (HTTP 200 + non-empty content) and assert the local server had no unhandled exceptions.
- Temporarily override
ServicePointManager.ServerCertificateValidationCallbackduring the request (with restoration afterward).
Show a summary per file
| File | Description |
|---|---|
| tests/Mono.Android-Tests/Mono.Android-Tests/System.Net/SslTest.cs | Switch HttpsShouldWork to use the in-process local HTTPS test server instead of external sites. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 1
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Jul 14, 2026
simonrozsival added a commit
that referenced
this pull request
Jul 14, 2026
> Re-opened as a direct PR (supersedes #12098) so the `dotnet-android` pipeline runs automatically without `/azp run` approval. ### Context Following up on #12022 (which migrated most on-device networking tests off live external URLs to the loopback `LocalHttpServer`/`LocalHttpsServer`) and #12058 (which handles `SslTest.HttpsShouldWork`), a few on-device tests were still reaching out to the public internet. Those requests made the tests flaky whenever the external endpoints were slow, rate-limited, or unavailable. This migrates the remaining tests to local loopback servers. ### Tests migrated | Test | Was hitting | | ---- | ----------- | | `SslTest.SslWithinTasksShouldWork` | `dotnet.microsoft.com` | | `ProxyTest.QuoteInvalidQuoteUrlsShouldWork` | `msftconnecttest.com` | | `AndroidMessageHandlerTests.ServerCertificateCustomValidationCallback_ApproveRequest` | `www.microsoft.com` | | `AndroidMessageHandlerTests.ServerCertificateCustomValidationCallback_RejectRequest` | `www.microsoft.com` | | `AndroidMessageHandlerTests.AndroidMessageHandlerSendsClientCertificate` | `corefx-net-tls.azurewebsites.net` | | `AndroidMessageHandlerIntegrationTests.GetString_Many` | `google.com` | | `HttpClientHandlerTestBase.Disposed` | `google.com` | | `WebSocketTests.TestSocketConnection` | `echo.websocket.org` (was `[Ignore]`d) | `ProxyTest` keeps its original point — an unescaped `|` in the query string (`?query&foo|bar`) — now exercised against the local `/ok` endpoint. `WebSocketTests` was previously disabled because the public echo server no longer exists; it is re-enabled against a local server. ### Test infrastructure (`LocalTestServers.cs`) - **Client certificates (mutual TLS)**: `LocalHttpsServer.Start (requestClientCertificate: true)` now requests a client certificate during the TLS handshake, and a new `/echo-client-certificate` endpoint returns the certificate the server received (base64 DER). This replaces the external `EchoClientCertificate.ashx` endpoint. - **`LocalWebSocketServer`**: a loopback WebSocket echo server that performs the upgrade handshake and echoes messages back (uses `WebSocket.CreateFromStream` after a manual `101 Switching Protocols` response). ### Notes - `HttpsShouldWork` is intentionally left to #12058. - The `http://10.255.255.1` cancellation/timeout tests deliberately use an unroutable address (not the public internet) and are unchanged. - Cosmetic external hostnames that were never actually contacted (`CancelRequestViaProxy`'s base address behind a dead proxy, and `DisallowAutoRedirect`'s redirect target) were pointed at `localhost`. The new server logic (HTTP, HTTPS, mutual-TLS echo, and WebSocket echo) was verified end-to-end against `HttpClient` and `ClientWebSocket` on desktop .NET.
simonrozsival
enabled auto-merge (squash)
July 14, 2026 14:03
jonathanpeppers
approved these changes
Jul 14, 2026
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 freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
HttpsShouldWorkdepended on live Microsoft and Bing endpoints, allowing external HTTP failures such as 504 responses to fail on-device tests.Local HTTPS coverage
LocalHttpsServer./okendpoint and verifies the response is HTTP 200 with content.Certificate handling
ServicePointManagercallback after the request.