Skip to content
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
abc791a
[Foundation] Implement NSUrlSessionHandler proxy support
rolfbjarne Jul 9, 2026
3430bf6
[Foundation] Fix NSUrlSessionHandler proxy authentication challenge h…
rolfbjarne Jul 9, 2026
cfef971
[tests] Update expected app size files for NSUrlSessionHandler proxy …
rolfbjarne Jul 9, 2026
28dfc09
[Foundation] Send proxy credentials via the connection proxy dictionary
rolfbjarne Jul 9, 2026
a0b5eb5
[Foundation] Revert ineffective proxy-dict credentials; add proxy tes…
rolfbjarne Jul 10, 2026
86dda0d
[Foundation] Test proxy authentication via HTTPS CONNECT tunnel
rolfbjarne Jul 10, 2026
12e3605
Auto-format source code
Jul 10, 2026
71319b4
[tests] Fix missing closing brace in ProxyTestServer.HandleConnect
rolfbjarne Jul 10, 2026
beec855
[tests] Fix proxy-auth tests: avoid CFNetwork localhost proxy bypass
rolfbjarne Jul 10, 2026
91e7078
Address PR review comments
rolfbjarne Jul 14, 2026
6027f05
Address PR review comments (round 2)
rolfbjarne Jul 14, 2026
d2aeaa4
[tests] Don't ignore CI failures for the local-only proxy tests
rolfbjarne Jul 15, 2026
127b6ad
[Foundation] Address proxy-support review feedback
rolfbjarne Jul 16, 2026
d4716ab
Merge remote-tracking branch 'origin/main' into dev/rolf/issue-14632-…
rolfbjarne Jul 17, 2026
4ecd0d5
[tests] Update expected sizes.
rolfbjarne Jul 17, 2026
6bbee6f
[Foundation] Throw for unsupported proxy schemes instead of silently …
rolfbjarne Jul 17, 2026
9e5575d
Merge remote-tracking branch 'origin/main' into dev/rolf/issue-14632-…
rolfbjarne Aug 3, 2026
44246da
[tests] Update expected sizes.
rolfbjarne Aug 3, 2026
6bffe0d
Merge remote-tracking branch 'origin/main' into dev/rolf/issue-14632-…
rolfbjarne Aug 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
227 changes: 197 additions & 30 deletions src/Foundation/NSUrlSessionHandler.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
AppBundleSize: 5,794,059 bytes (5,658.3 KB = 5.5 MB)
AppBundleSize: 5,793,245 bytes (5,657.5 KB = 5.5 MB)
# The following list of files and their sizes is just informational / for review, and isn't used in the test:
Contents/Info.plist:
1,078 bytes (1.1 KB = 0.0 MB)
1,096 bytes (1.1 KB = 0.0 MB)
Contents/MacOS/SizeTestApp:
4,573,752 bytes (4,466.6 KB = 4.4 MB)
4,572,920 bytes (4,465.7 KB = 4.4 MB)
Contents/MonoBundle/Microsoft.MacCatalyst.dll:
157,696 bytes (154.0 KB = 0.2 MB)
Contents/MonoBundle/runtimeconfig.bin:
Expand Down
6 changes: 3 additions & 3 deletions tests/dotnet/UnitTests/expected/MacCatalyst-MonoVM-size.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
AppBundleSize: 16,308,360 bytes (15,926.1 KB = 15.6 MB)
AppBundleSize: 16,308,569 bytes (15,926.3 KB = 15.6 MB)
# The following list of files and their sizes is just informational / for review, and isn't used in the test:
Contents/Info.plist:
1,079 bytes (1.1 KB = 0.0 MB)
1,096 bytes (1.1 KB = 0.0 MB)
Contents/MacOS/SizeTestApp:
13,801,288 bytes (13,477.8 KB = 13.2 MB)
13,801,480 bytes (13,478.0 KB = 13.2 MB)
Contents/MonoBundle/aot-instances.aotdata.arm64:
1,045,352 bytes (1,020.9 KB = 1.0 MB)
Contents/MonoBundle/Microsoft.MacCatalyst.aotdata.arm64:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
AppBundleSize: 8,772,055 bytes (8,566.5 KB = 8.4 MB)
AppBundleSize: 8,788,640 bytes (8,582.7 KB = 8.4 MB)
# The following list of files and their sizes is just informational / for review, and isn't used in the test:
Contents/Info.plist:
1,071 bytes (1.0 KB = 0.0 MB)
1,096 bytes (1.1 KB = 0.0 MB)
Contents/MacOS/SizeTestApp:
8,769,080 bytes (8,563.6 KB = 8.4 MB)
8,785,640 bytes (8,579.7 KB = 8.4 MB)
Contents/MonoBundle/runtimeconfig.bin:
1,896 bytes (1.9 KB = 0.0 MB)
Contents/PkgInfo:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
AppBundleSize: 2,742,214 bytes (2,677.9 KB = 2.6 MB)
AppBundleSize: 2,742,248 bytes (2,678.0 KB = 2.6 MB)
# The following list of files and their sizes is just informational / for review, and isn't used in the test:
Contents/Info.plist:
1,062 bytes (1.0 KB = 0.0 MB)
1,096 bytes (1.1 KB = 0.0 MB)
Contents/MacOS/SizeTestApp:
2,739,336 bytes (2,675.1 KB = 2.6 MB)
Contents/MonoBundle/runtimeconfig.bin:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
AppBundleSize: 257,724,211 bytes (251,683.8 KB = 245.8 MB)
AppBundleSize: 257,735,803 bytes (251,695.1 KB = 245.8 MB)
# The following list of files and their sizes is just informational / for review, and isn't used in the test:
Contents/Info.plist:
718 bytes (0.7 KB = 0.0 MB)
774 bytes (0.8 KB = 0.0 MB)
Contents/MacOS/SizeTestApp:
7,386,728 bytes (7,213.6 KB = 7.0 MB)
7,388,024 bytes (7,214.9 KB = 7.0 MB)
Contents/MonoBundle/.xamarin/osx-arm64/_Microsoft.macOS.TypeMap.dll:
4,911,616 bytes (4,796.5 KB = 4.7 MB)
Contents/MonoBundle/.xamarin/osx-arm64/_SizeTestApp.TypeMap.dll:
3,072 bytes (3.0 KB = 0.0 MB)
3,584 bytes (3.5 KB = 0.0 MB)
Contents/MonoBundle/.xamarin/osx-arm64/Microsoft.CSharp.dll:
892,712 bytes (871.8 KB = 0.9 MB)
Contents/MonoBundle/.xamarin/osx-arm64/Microsoft.macOS.dll:
37,213,184 bytes (36,341.0 KB = 35.5 MB)
37,217,792 bytes (36,345.5 KB = 35.5 MB)
Contents/MonoBundle/.xamarin/osx-arm64/Microsoft.VisualBasic.Core.dll:
1,334,568 bytes (1,303.3 KB = 1.3 MB)
Contents/MonoBundle/.xamarin/osx-arm64/Microsoft.VisualBasic.dll:
Expand Down Expand Up @@ -359,11 +359,11 @@ Contents/MonoBundle/.xamarin/osx-arm64/WindowsBase.dll:
Contents/MonoBundle/.xamarin/osx-x64/_Microsoft.macOS.TypeMap.dll:
4,911,616 bytes (4,796.5 KB = 4.7 MB)
Contents/MonoBundle/.xamarin/osx-x64/_SizeTestApp.TypeMap.dll:
3,072 bytes (3.0 KB = 0.0 MB)
3,584 bytes (3.5 KB = 0.0 MB)
Contents/MonoBundle/.xamarin/osx-x64/Microsoft.CSharp.dll:
795,944 bytes (777.3 KB = 0.8 MB)
Contents/MonoBundle/.xamarin/osx-x64/Microsoft.macOS.dll:
37,213,184 bytes (36,341.0 KB = 35.5 MB)
37,217,792 bytes (36,345.5 KB = 35.5 MB)
Contents/MonoBundle/.xamarin/osx-x64/Microsoft.VisualBasic.Core.dll:
1,166,120 bytes (1,138.8 KB = 1.1 MB)
Contents/MonoBundle/.xamarin/osx-x64/Microsoft.VisualBasic.dll:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
AppBundleSize: 247,975,409 bytes (242,163.5 KB = 236.5 MB)
AppBundleSize: 247,985,977 bytes (242,173.8 KB = 236.5 MB)
# The following list of files and their sizes is just informational / for review, and isn't used in the test:
Contents/Info.plist:
718 bytes (0.7 KB = 0.0 MB)
774 bytes (0.8 KB = 0.0 MB)
Contents/MacOS/SizeTestApp:
8,028,536 bytes (7,840.4 KB = 7.7 MB)
8,029,832 bytes (7,841.6 KB = 7.7 MB)
Contents/MonoBundle/.xamarin/osx-arm64/Microsoft.CSharp.dll:
892,712 bytes (871.8 KB = 0.9 MB)
Contents/MonoBundle/.xamarin/osx-arm64/Microsoft.macOS.dll:
36,932,096 bytes (36,066.5 KB = 35.2 MB)
36,936,704 bytes (36,071.0 KB = 35.2 MB)
Contents/MonoBundle/.xamarin/osx-arm64/Microsoft.VisualBasic.Core.dll:
1,334,568 bytes (1,303.3 KB = 1.3 MB)
Contents/MonoBundle/.xamarin/osx-arm64/Microsoft.VisualBasic.dll:
Expand Down Expand Up @@ -355,7 +355,7 @@ Contents/MonoBundle/.xamarin/osx-arm64/WindowsBase.dll:
Contents/MonoBundle/.xamarin/osx-x64/Microsoft.CSharp.dll:
795,944 bytes (777.3 KB = 0.8 MB)
Contents/MonoBundle/.xamarin/osx-x64/Microsoft.macOS.dll:
36,932,096 bytes (36,066.5 KB = 35.2 MB)
36,936,704 bytes (36,071.0 KB = 35.2 MB)
Contents/MonoBundle/.xamarin/osx-x64/Microsoft.VisualBasic.Core.dll:
1,166,120 bytes (1,138.8 KB = 1.1 MB)
Contents/MonoBundle/.xamarin/osx-x64/Microsoft.VisualBasic.dll:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
AppBundleSize: 21,463,772 bytes (20,960.7 KB = 20.5 MB)
AppBundleSize: 21,496,766 bytes (20,992.9 KB = 20.5 MB)
# The following list of files and their sizes is just informational / for review, and isn't used in the test:
Contents/Info.plist:
740 bytes (0.7 KB = 0.0 MB)
774 bytes (0.8 KB = 0.0 MB)
Contents/MacOS/SizeTestApp:
18,374,472 bytes (17,943.8 KB = 17.5 MB)
18,407,432 bytes (17,976.0 KB = 17.6 MB)
Contents/MonoBundle/libSystem.Globalization.Native.dylib:
267,872 bytes (261.6 KB = 0.3 MB)
Contents/MonoBundle/libSystem.IO.Compression.Native.dylib:
Expand Down
4 changes: 2 additions & 2 deletions tests/dotnet/UnitTests/expected/MacOSX-NativeAOT-size.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
AppBundleSize: 8,779,453 bytes (8,573.7 KB = 8.4 MB)
AppBundleSize: 8,779,452 bytes (8,573.7 KB = 8.4 MB)
# The following list of files and their sizes is just informational / for review, and isn't used in the test:
Contents/Info.plist:
775 bytes (0.8 KB = 0.0 MB)
774 bytes (0.8 KB = 0.0 MB)
Contents/MacOS/SizeTestApp:
5,690,200 bytes (5,556.8 KB = 5.4 MB)
Contents/MonoBundle/libSystem.Globalization.Native.dylib:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
AppBundleSize: 3,571,125 bytes (3,487.4 KB = 3.4 MB)
AppBundleSize: 3,571,143 bytes (3,487.4 KB = 3.4 MB)
# The following list of files and their sizes is just informational / for review, and isn't used in the test:
Info.plist:
1,144 bytes (1.1 KB = 0.0 MB)
1,162 bytes (1.1 KB = 0.0 MB)
Microsoft.tvOS.dll:
152,064 bytes (148.5 KB = 0.1 MB)
PkgInfo:
Expand Down
6 changes: 3 additions & 3 deletions tests/dotnet/UnitTests/expected/TVOS-MonoVM-size.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
AppBundleSize: 9,249,490 bytes (9,032.7 KB = 8.8 MB)
AppBundleSize: 9,249,499 bytes (9,032.7 KB = 8.8 MB)
# The following list of files and their sizes is just informational / for review, and isn't used in the test:
aot-instances.aotdata.arm64:
827,728 bytes (808.3 KB = 0.8 MB)
Info.plist:
1,145 bytes (1.1 KB = 0.0 MB)
1,162 bytes (1.1 KB = 0.0 MB)
Microsoft.tvOS.aotdata.arm64:
22,872 bytes (22.3 KB = 0.0 MB)
Microsoft.tvOS.dll:
Expand All @@ -13,7 +13,7 @@ PkgInfo:
runtimeconfig.bin:
1,481 bytes (1.4 KB = 0.0 MB)
SizeTestApp:
7,151,952 bytes (6,984.3 KB = 6.8 MB)
7,151,944 bytes (6,984.3 KB = 6.8 MB)
SizeTestApp.aotdata.arm64:
1,464 bytes (1.4 KB = 0.0 MB)
SizeTestApp.dll:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
AppBundleSize: 7,804,745 bytes (7,621.8 KB = 7.4 MB)
AppBundleSize: 7,821,227 bytes (7,637.9 KB = 7.5 MB)
# The following list of files and their sizes is just informational / for review, and isn't used in the test:
Info.plist:
1,128 bytes (1.1 KB = 0.0 MB)
1,162 bytes (1.1 KB = 0.0 MB)
PkgInfo:
8 bytes (0.0 KB = 0.0 MB)
runtimeconfig.bin:
1,889 bytes (1.8 KB = 0.0 MB)
SizeTestApp:
7,801,720 bytes (7,618.9 KB = 7.4 MB)
7,818,168 bytes (7,634.9 KB = 7.5 MB)
4 changes: 2 additions & 2 deletions tests/dotnet/UnitTests/expected/TVOS-NativeAOT-size.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
AppBundleSize: 2,705,640 bytes (2,642.2 KB = 2.6 MB)
AppBundleSize: 2,705,674 bytes (2,642.3 KB = 2.6 MB)
# The following list of files and their sizes is just informational / for review, and isn't used in the test:
Info.plist:
1,128 bytes (1.1 KB = 0.0 MB)
1,162 bytes (1.1 KB = 0.0 MB)
PkgInfo:
8 bytes (0.0 KB = 0.0 MB)
runtimeconfig.bin:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
AppBundleSize: 3,571,429 bytes (3,487.7 KB = 3.4 MB)
AppBundleSize: 3,571,447 bytes (3,487.7 KB = 3.4 MB)
# The following list of files and their sizes is just informational / for review, and isn't used in the test:
Info.plist:
1,168 bytes (1.1 KB = 0.0 MB)
1,186 bytes (1.2 KB = 0.0 MB)
Microsoft.iOS.dll:
152,064 bytes (148.5 KB = 0.1 MB)
PkgInfo:
Expand Down
4 changes: 2 additions & 2 deletions tests/dotnet/UnitTests/expected/iOS-MonoVM-size.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
AppBundleSize: 9,249,530 bytes (9,032.7 KB = 8.8 MB)
AppBundleSize: 9,249,547 bytes (9,032.8 KB = 8.8 MB)
# The following list of files and their sizes is just informational / for review, and isn't used in the test:
aot-instances.aotdata.arm64:
827,728 bytes (808.3 KB = 0.8 MB)
Info.plist:
1,169 bytes (1.1 KB = 0.0 MB)
1,186 bytes (1.2 KB = 0.0 MB)
Microsoft.iOS.aotdata.arm64:
23,216 bytes (22.7 KB = 0.0 MB)
Microsoft.iOS.dll:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
AppBundleSize: 8,981,873 bytes (8,771.4 KB = 8.6 MB)
AppBundleSize: 8,998,346 bytes (8,787.4 KB = 8.6 MB)
# The following list of files and their sizes is just informational / for review, and isn't used in the test:
Info.plist:
1,161 bytes (1.1 KB = 0.0 MB)
1,186 bytes (1.2 KB = 0.0 MB)
PkgInfo:
8 bytes (0.0 KB = 0.0 MB)
runtimeconfig.bin:
1,888 bytes (1.8 KB = 0.0 MB)
SizeTestApp:
8,978,816 bytes (8,768.4 KB = 8.6 MB)
8,995,264 bytes (8,784.4 KB = 8.6 MB)
4 changes: 2 additions & 2 deletions tests/dotnet/UnitTests/expected/iOS-NativeAOT-size.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
AppBundleSize: 2,706,000 bytes (2,642.6 KB = 2.6 MB)
AppBundleSize: 2,706,034 bytes (2,642.6 KB = 2.6 MB)
# The following list of files and their sizes is just informational / for review, and isn't used in the test:
Info.plist:
1,152 bytes (1.1 KB = 0.0 MB)
1,186 bytes (1.2 KB = 0.0 MB)
PkgInfo:
8 bytes (0.0 KB = 0.0 MB)
runtimeconfig.bin:
Expand Down
77 changes: 3 additions & 74 deletions tests/monotouch-test/System.Net.Http/MessageHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ public void TestNSUrlSessionHandlerOptionalClientCertificate ()
{
NWListener? listener = null;
try {
listener = CreateNWTlsListener (requireClientCert: false);
listener = TlsTestServer.CreateNWTlsListener (requireClientCert: false);
var port = listener.Port;

var done = TestRuntime.TryRunAsync (TimeSpan.FromSeconds (30), async () => {
Expand All @@ -861,7 +861,7 @@ public void TestNSUrlSessionHandlerDetectMissingClientCertificate ()
{
NWListener? listener = null;
try {
listener = CreateNWTlsListener (requireClientCert: true);
listener = TlsTestServer.CreateNWTlsListener (requireClientCert: true);
var port = listener.Port;

var done = TestRuntime.TryRunAsync (TimeSpan.FromSeconds (30), async () => {
Expand Down Expand Up @@ -889,7 +889,7 @@ public void TestNSUrlSessionHandlerDetectMissingClientCertificateOptOut ()
NWListener? listener = null;
try {
AppContext.SetSwitch ("Foundation.NSUrlSessionHandler.NoMissingCertificateHandling", true);
listener = CreateNWTlsListener (requireClientCert: true);
listener = TlsTestServer.CreateNWTlsListener (requireClientCert: true);
var port = listener.Port;

var done = TestRuntime.TryRunAsync (TimeSpan.FromSeconds (30), async () => {
Expand All @@ -912,77 +912,6 @@ public void TestNSUrlSessionHandlerDetectMissingClientCertificateOptOut ()
}
}

static NWListener CreateNWTlsListener (bool requireClientCert)
{
var (pfxData, pfxPassword) = CreateSelfSignedServerCertificatePfx ();
using var secIdentity = SecIdentity.Import (pfxData, pfxPassword);
using var secIdentity2 = new SecIdentity2 (secIdentity);
using var readyEvent = new ManualResetEventSlim (false);
NWError? listenerError = null;

var parameters = NWParameters.CreateSecureTcp (
configureTls: tlsOptions => {
var tls = (NWProtocolTlsOptions) tlsOptions;
var secOptions = tls.ProtocolOptions;
secOptions.SetLocalIdentity (secIdentity2);
secOptions.SetPeerAuthenticationRequired (requireClientCert);
});
using var localEndpoint = NWEndpoint.Create ("127.0.0.1", "0");
parameters.LocalEndpoint = localEndpoint;

var listener = NWListener.Create (parameters);
parameters.Dispose ();

listener.SetQueue (CoreFoundation.DispatchQueue.DefaultGlobalQueue);

listener.SetStateChangedHandler ((state, error) => {
if (state == NWListenerState.Failed)
listenerError = error;
if (state == NWListenerState.Ready || state == NWListenerState.Failed)
readyEvent.Set ();
});

listener.SetNewConnectionHandler (connection => {
connection.SetQueue (CoreFoundation.DispatchQueue.DefaultGlobalQueue);
connection.SetStateChangeHandler ((connState, connError) => {
if (connState == NWConnectionState.Ready) {
// Read the HTTP request (just consume it), then send a response
connection.ReceiveReadOnlyData (1, 4096, (data, context, isComplete, error) => {
var response = Encoding.UTF8.GetBytes ("HTTP/1.1 200 OK\r\nContent-Length: 2\r\nConnection: close\r\n\r\nOK");
connection.Send (response, NWContentContext.FinalMessage, true, sendError => {
connection.Cancel ();
});
});
}
});
connection.Start ();
});

listener.Start ();

if (!readyEvent.Wait (TimeSpan.FromSeconds (10)))
throw new TimeoutException ("NWListener did not become ready in time.");

if (listenerError is not null)
throw new InvalidOperationException ($"NWListener failed to start: {listenerError}");

return listener;
}

static (byte [] Data, string Password) CreateSelfSignedServerCertificatePfx ()
{
using var rsa = RSA.Create (2048);
var certRequest = new CertificateRequest (
"CN=localhost", rsa, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
var sanBuilder = new SubjectAlternativeNameBuilder ();
sanBuilder.AddIpAddress (IPAddress.Loopback);
sanBuilder.AddDnsName ("localhost");
certRequest.CertificateExtensions.Add (sanBuilder.Build ());
var cert = certRequest.CreateSelfSigned (DateTimeOffset.UtcNow.AddDays (-1), DateTimeOffset.UtcNow.AddYears (1));
var password = Guid.NewGuid ().ToString ();
return (cert.Export (X509ContentType.Pfx, password), password);
}

sealed class RedirectBasicAuthServer : IDisposable {
readonly bool crossOrigin;
readonly HttpListener originListener;
Expand Down
Loading
Loading