Skip to content

Commit 82c1136

Browse files
committed
Change runtime identifier check to regex
1 parent 6b21cb1 commit 82c1136

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

src/libraries/Common/tests/System/Net/Capability.Security.Unix.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.Runtime.InteropServices;
5+
using System.Text.RegularExpressions;
56

67
namespace System.Net.Test.Common
78
{
@@ -11,7 +12,7 @@ public static bool IsNtlmInstalled()
1112
{
1213
return
1314
// Linux bionic uses managed NTLM implementation
14-
OperatingSystem.IsLinux() && RuntimeInformation.RuntimeIdentifier.StartsWith("linux-bionic", StringComparison.OrdinalIgnoreCase) ||
15+
OperatingSystem.IsLinux() && Regex.IsMatch(RuntimeInformation.RuntimeIdentifier, "^linux-bionic(-.*)?$", RegexOptions.CultureInvariant | RegexOptions.NonBacktracking | RegexOptions.ExplicitCapture) ||
1516
// GSS on Linux does not work with OpenSSL 3.0. Fix was submitted to gss-ntlm but it will take a while to make to
1617
// all supported distributions. The second part of the check should be removed when it does.
1718
Interop.NetSecurityNative.IsNtlmInstalled() && (!PlatformDetection.IsOpenSslSupported || PlatformDetection.OpenSslVersion.Major < 3);

src/libraries/System.Net.Security/src/System.Net.Security.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@
462462
<Reference Include="System.Security.Claims" />
463463
<Reference Include="System.Security.Cryptography" />
464464
<Reference Include="System.Security.Principal.Windows" />
465+
<Reference Include="System.Text.RegularExpressions" />
465466
<Reference Include="System.Threading" />
466467
<Reference Include="System.Threading.ThreadPool" />
467468
</ItemGroup>

src/libraries/System.Net.Security/src/System/Net/NegotiateAuthenticationPal.Unix.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using System.Security.Authentication.ExtendedProtection;
1414
using System.Security.Principal;
1515
using System.Text;
16+
using System.Text.RegularExpressions;
1617
using Microsoft.Win32.SafeHandles;
1718

1819
namespace System.Net
@@ -25,7 +26,7 @@ internal partial class NegotiateAuthenticationPal
2526
AppContext.TryGetSwitch("System.Net.Security.UseManagedNtlm", out bool useManagedNtlm) ?
2627
useManagedNtlm :
2728
OperatingSystem.IsMacOS() || OperatingSystem.IsIOS() || OperatingSystem.IsMacCatalyst() ||
28-
(OperatingSystem.IsLinux() && RuntimeInformation.RuntimeIdentifier.StartsWith("linux-bionic", StringComparison.OrdinalIgnoreCase));
29+
(OperatingSystem.IsLinux() && Regex.IsMatch(RuntimeInformation.RuntimeIdentifier, "^linux-bionic(-.*)?$", RegexOptions.CultureInvariant | RegexOptions.NonBacktracking | RegexOptions.ExplicitCapture));
2930

3031
public static NegotiateAuthenticationPal Create(NegotiateAuthenticationClientOptions clientOptions)
3132
{

0 commit comments

Comments
 (0)