diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Windows.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Windows.cs index c51437bae4f2c..6448f7cc42d4b 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Windows.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Windows.cs @@ -61,7 +61,7 @@ public static partial class PlatformDetection // Windows Server 2022 public static bool IsWindows10Version20348OrGreater => IsWindowsVersionOrLater(10, 0, 20348); - + public static bool IsWindows10Version20348OrLower => IsWindowsVersionOrEarlier(10, 0, 20348); // Windows 11 aka 21H2 public static bool IsWindows10Version22000OrGreater => IsWindowsVersionOrLater(10, 0, 22000); @@ -179,6 +179,11 @@ internal static bool IsWindowsVersionOrLater(int major, int minor, int build = - return IsWindows && GetWindowsVersionObject() >= (build != -1 ? new Version(major, minor, build) : new Version(major, minor)); } + internal static bool IsWindowsVersionOrEarlier(int major, int minor, int build = -1) + { + return IsWindows && GetWindowsVersionObject() <= (build != -1 ? new Version(major, minor, build) : new Version(major, minor)); + } + private static int s_isInAppContainer = -1; public static bool IsInAppContainer { diff --git a/src/libraries/System.Net.Quic/tests/FunctionalTests/MsQuicTests.cs b/src/libraries/System.Net.Quic/tests/FunctionalTests/MsQuicTests.cs index fe8a3eb1d9a2e..2876d33551a6c 100644 --- a/src/libraries/System.Net.Quic/tests/FunctionalTests/MsQuicTests.cs +++ b/src/libraries/System.Net.Quic/tests/FunctionalTests/MsQuicTests.cs @@ -105,9 +105,14 @@ public async Task ConnectWithCertificateChain() clientConnection.Dispose(); } - [Fact] + [ConditionalFact] public async Task UntrustedClientCertificateFails() { + if (PlatformDetection.IsWindows10Version20348OrLower) + { + throw new SkipTestException("Client certificates are not supported on Windows Server 2022."); + } + var listenerOptions = new QuicListenerOptions(); listenerOptions.ListenEndPoint = new IPEndPoint(IPAddress.Loopback, 0); listenerOptions.ServerAuthenticationOptions = GetSslServerAuthenticationOptions(); @@ -334,11 +339,16 @@ public async Task ConnectWithCertificateForLoopbackIP_IndicatesExpectedError(str (QuicConnection clientConnection, QuicConnection serverConnection) = await CreateConnectedQuicConnection(clientOptions, listenerOptions); } - [Theory] + [ConditionalTheory] [InlineData(true)] [InlineData(false)] public async Task ConnectWithClientCertificate(bool sendCertificate) { + if (PlatformDetection.IsWindows10Version20348OrLower) + { + throw new SkipTestException("Client certificates are not supported on Windows Server 2022."); + } + bool clientCertificateOK = false; var listenerOptions = new QuicListenerOptions();