From 48dd36780f7826b4a8ef4d1b1ede060a82b3cf64 Mon Sep 17 00:00:00 2001 From: Steve Pfister Date: Fri, 9 Sep 2022 11:09:45 -0400 Subject: [PATCH] Fix WebSockets.Client.ConnectTest crash for apple mobile platforms https://github.com/dotnet/runtime/pull/74473 had a change where we started adding a client certificate that is not supported on apple mobile platforms. This lead to an unhandled exception in the MemberData setup of ConnectAsync_CustomInvokerWithIncompatibleWebSocketOptions_ThrowsArgumentException and resulted in an app crash. Addresses https://github.com/dotnet/runtime/issues/75307 --- .../System.Net.WebSockets.Client/tests/ConnectTest.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs b/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs index 3b167b39bf8487..1f48c534e34dfa 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs +++ b/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs @@ -25,7 +25,14 @@ public static IEnumerable ConnectAsync_CustomInvokerWithIncompatibleWe yield return NoThrow(options => options.UseDefaultCredentials = false); yield return Throw(options => options.Credentials = new NetworkCredential()); yield return Throw(options => options.Proxy = new WebProxy()); - yield return Throw(options => options.ClientCertificates.Add(Test.Common.Configuration.Certificates.GetClientCertificate())); + + // Will result in an exception on apple mobile platforms + // and crash the test. + if (PlatformDetection.IsNotAppleMobile) + { + yield return Throw(options => options.ClientCertificates.Add(Test.Common.Configuration.Certificates.GetClientCertificate())); + } + yield return NoThrow(options => options.ClientCertificates = new X509CertificateCollection()); yield return Throw(options => options.RemoteCertificateValidationCallback = delegate { return true; }); yield return Throw(options => options.Cookies = new CookieContainer());