From 7bf5f09a1012ef565f7169623cc73071aa9b385b Mon Sep 17 00:00:00 2001 From: Tomas Weinfurt Date: Sat, 23 May 2020 12:24:16 -0700 Subject: [PATCH 1/4] Improve test ALPN detection --- .../tests/TestUtilities/System/PlatformDetection.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs index df828e0f7eeff7..b872dbe49e6bb7 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs @@ -24,6 +24,7 @@ public static partial class PlatformDetection public static bool IsMonoInterpreter => GetIsRunningOnMonoInterpreter(); public static bool IsFreeBSD => RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD")); public static bool IsNetBSD => RuntimeInformation.IsOSPlatform(OSPlatform.Create("NETBSD")); + public static bool IsIOS => RuntimeInformation.IsOSPlatform(OSPlatform.Create("IOS")); public static bool IsArmProcess => RuntimeInformation.ProcessArchitecture == Architecture.Arm; public static bool IsNotArmProcess => !IsArmProcess; @@ -109,11 +110,13 @@ public static bool IsNonZeroLowerBoundArraySupported // Windows - Schannel supports alpn from win8.1/2012 R2 and higher. // Linux - OpenSsl supports alpn from openssl 1.0.2 and higher. // OSX - SecureTransport doesn't expose alpn APIs. TODO https://github.com/dotnet/runtime/issues/27727 + public static bool IsOpenSslSupported => IsLinux || IsFreeBSD; + public static bool SupportsAlpn => (IsWindows && !IsWindows7) || - ((!IsOSX && !IsWindows) && + (IsOpenSslSupported && (OpenSslVersion.Major >= 1 && (OpenSslVersion.Minor >= 1 || OpenSslVersion.Build >= 2))); - public static bool SupportsClientAlpn => SupportsAlpn || (IsOSX && Environment.OSVersion.Version > new Version(10, 12)); + public static bool SupportsClientAlpn => SupportsAlpn || IsOSX || IsIOS; // OpenSSL 1.1.1 and above. public static bool SupportsTls13 => GetTls13Support(); @@ -266,11 +269,13 @@ private static bool GetTls13Support() // [ActiveIssue("https://github.com/dotnet/runtime/issues/1979")] return false; } - else + else if (IsLinux) { // Covers Linux and FreeBSD return OpenSslVersion >= new Version(1,1,1); } + + return false; } private static bool GetIsRunningOnMonoInterpreter() From ec865a07672074909a97ff8838b95acae94deda7 Mon Sep 17 00:00:00 2001 From: Tomas Weinfurt Date: Tue, 26 May 2020 10:51:39 -0700 Subject: [PATCH 2/4] feedback from review --- .../Common/tests/TestUtilities/System/PlatformDetection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs index b872dbe49e6bb7..3d718134d13902 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs @@ -269,7 +269,7 @@ private static bool GetTls13Support() // [ActiveIssue("https://github.com/dotnet/runtime/issues/1979")] return false; } - else if (IsLinux) + else if (IsOpenSslSupported) { // Covers Linux and FreeBSD return OpenSslVersion >= new Version(1,1,1); From 21cb01a4a02b15256c280f3df98afd7bdd00df78 Mon Sep 17 00:00:00 2001 From: Tomas Weinfurt Date: Tue, 26 May 2020 15:22:41 -0700 Subject: [PATCH 3/4] add tvos --- .../Common/tests/TestUtilities/System/PlatformDetection.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs index 3d718134d13902..11bd2909bed2e8 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs @@ -25,6 +25,7 @@ public static partial class PlatformDetection public static bool IsFreeBSD => RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD")); public static bool IsNetBSD => RuntimeInformation.IsOSPlatform(OSPlatform.Create("NETBSD")); public static bool IsIOS => RuntimeInformation.IsOSPlatform(OSPlatform.Create("IOS")); + public static bool IsTvOS => RuntimeInformation.IsOSPlatform(OSPlatform.Create("TVOS")); public static bool IsArmProcess => RuntimeInformation.ProcessArchitecture == Architecture.Arm; public static bool IsNotArmProcess => !IsArmProcess; @@ -116,7 +117,7 @@ public static bool IsNonZeroLowerBoundArraySupported (IsOpenSslSupported && (OpenSslVersion.Major >= 1 && (OpenSslVersion.Minor >= 1 || OpenSslVersion.Build >= 2))); - public static bool SupportsClientAlpn => SupportsAlpn || IsOSX || IsIOS; + public static bool SupportsClientAlpn => SupportsAlpn || IsOSX || IsIOS || IsTvOS; // OpenSSL 1.1.1 and above. public static bool SupportsTls13 => GetTls13Support(); @@ -264,7 +265,7 @@ private static bool GetTls13Support() // assume no if key is missing or on error. return false; } - else if (IsOSX) + else if (IsOSX || IsIOS || IsTvOS) { // [ActiveIssue("https://github.com/dotnet/runtime/issues/1979")] return false; From 53387baed6282d3a3518271483a419c687dbcbfb Mon Sep 17 00:00:00 2001 From: Tomas Weinfurt Date: Tue, 26 May 2020 15:32:51 -0700 Subject: [PATCH 4/4] update casing --- .../tests/TestUtilities/System/PlatformDetection.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs index 11bd2909bed2e8..a17d3eebce28dc 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs @@ -24,8 +24,8 @@ public static partial class PlatformDetection public static bool IsMonoInterpreter => GetIsRunningOnMonoInterpreter(); public static bool IsFreeBSD => RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD")); public static bool IsNetBSD => RuntimeInformation.IsOSPlatform(OSPlatform.Create("NETBSD")); - public static bool IsIOS => RuntimeInformation.IsOSPlatform(OSPlatform.Create("IOS")); - public static bool IsTvOS => RuntimeInformation.IsOSPlatform(OSPlatform.Create("TVOS")); + public static bool IsiOS => RuntimeInformation.IsOSPlatform(OSPlatform.Create("IOS")); + public static bool IstvOS => RuntimeInformation.IsOSPlatform(OSPlatform.Create("TVOS")); public static bool IsArmProcess => RuntimeInformation.ProcessArchitecture == Architecture.Arm; public static bool IsNotArmProcess => !IsArmProcess; @@ -117,7 +117,7 @@ public static bool IsNonZeroLowerBoundArraySupported (IsOpenSslSupported && (OpenSslVersion.Major >= 1 && (OpenSslVersion.Minor >= 1 || OpenSslVersion.Build >= 2))); - public static bool SupportsClientAlpn => SupportsAlpn || IsOSX || IsIOS || IsTvOS; + public static bool SupportsClientAlpn => SupportsAlpn || IsOSX || IsiOS || IstvOS; // OpenSSL 1.1.1 and above. public static bool SupportsTls13 => GetTls13Support(); @@ -265,7 +265,7 @@ private static bool GetTls13Support() // assume no if key is missing or on error. return false; } - else if (IsOSX || IsIOS || IsTvOS) + else if (IsOSX || IsiOS || IstvOS) { // [ActiveIssue("https://github.com/dotnet/runtime/issues/1979")] return false;