Skip to content

Commit b42753b

Browse files
authored
Improve test ALPN detection (dotnet#36928)
* Improve test ALPN detection * feedback from review * add tvos * update casing
1 parent a890e65 commit b42753b

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public static partial class PlatformDetection
2424
public static bool IsMonoInterpreter => GetIsRunningOnMonoInterpreter();
2525
public static bool IsFreeBSD => RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD"));
2626
public static bool IsNetBSD => RuntimeInformation.IsOSPlatform(OSPlatform.Create("NETBSD"));
27+
public static bool IsiOS => RuntimeInformation.IsOSPlatform(OSPlatform.Create("IOS"));
28+
public static bool IstvOS => RuntimeInformation.IsOSPlatform(OSPlatform.Create("TVOS"));
2729

2830
public static bool IsArmProcess => RuntimeInformation.ProcessArchitecture == Architecture.Arm;
2931
public static bool IsNotArmProcess => !IsArmProcess;
@@ -109,11 +111,13 @@ public static bool IsNonZeroLowerBoundArraySupported
109111
// Windows - Schannel supports alpn from win8.1/2012 R2 and higher.
110112
// Linux - OpenSsl supports alpn from openssl 1.0.2 and higher.
111113
// OSX - SecureTransport doesn't expose alpn APIs. TODO https://github.com/dotnet/runtime/issues/27727
114+
public static bool IsOpenSslSupported => IsLinux || IsFreeBSD;
115+
112116
public static bool SupportsAlpn => (IsWindows && !IsWindows7) ||
113-
((!IsOSX && !IsWindows) &&
117+
(IsOpenSslSupported &&
114118
(OpenSslVersion.Major >= 1 && (OpenSslVersion.Minor >= 1 || OpenSslVersion.Build >= 2)));
115119

116-
public static bool SupportsClientAlpn => SupportsAlpn || (IsOSX && Environment.OSVersion.Version > new Version(10, 12));
120+
public static bool SupportsClientAlpn => SupportsAlpn || IsOSX || IsiOS || IstvOS;
117121

118122
// OpenSSL 1.1.1 and above.
119123
public static bool SupportsTls13 => GetTls13Support();
@@ -261,16 +265,18 @@ private static bool GetTls13Support()
261265
// assume no if key is missing or on error.
262266
return false;
263267
}
264-
else if (IsOSX)
268+
else if (IsOSX || IsiOS || IstvOS)
265269
{
266270
// [ActiveIssue("https://github.com/dotnet/runtime/issues/1979")]
267271
return false;
268272
}
269-
else
273+
else if (IsOpenSslSupported)
270274
{
271275
// Covers Linux and FreeBSD
272276
return OpenSslVersion >= new Version(1,1,1);
273277
}
278+
279+
return false;
274280
}
275281

276282
private static bool GetIsRunningOnMonoInterpreter()

0 commit comments

Comments
 (0)