@@ -19,35 +19,11 @@ namespace System.Net
1919{
2020 internal partial class NegotiateAuthenticationPal
2121 {
22- private static bool _useManagedNtlm ;
23- private static bool _isGssApiAvailable ;
24-
25- #pragma warning disable CA1810 // explicit static cctor
26- static NegotiateAuthenticationPal ( )
27- {
28- try
29- {
30- if ( ! Interop . NetSecurityNative . IsNtlmInstalled ( ) )
31- {
32- _useManagedNtlm = ! AppContext . TryGetSwitch ( "System.Net.Security.UseManagedNtlm" , out bool useManagedNtlm ) || useManagedNtlm ;
33- }
34- else
35- {
36- _useManagedNtlm = AppContext . TryGetSwitch ( "System.Net.Security.UseManagedNtlm" , out bool useManagedNtlm ) && useManagedNtlm ;
37- }
38- _isGssApiAvailable = true ;
39- }
40- catch ( EntryPointNotFoundException )
41- {
42- // GSSAPI shim may not be available on some platforms (Linux Bionic)
43- _isGssApiAvailable = false ;
44- }
45- }
46- #pragma warning restore CA1810
22+ private static bool UseManagedNtlm { get ; } = AppContext . TryGetSwitch ( "System.Net.Security.UseManagedNtlm" , out bool useManagedNtlm ) && useManagedNtlm ;
4723
4824 public static NegotiateAuthenticationPal Create ( NegotiateAuthenticationClientOptions clientOptions )
4925 {
50- if ( _useManagedNtlm )
26+ if ( UseManagedNtlm )
5127 {
5228 switch ( clientOptions . Package )
5329 {
@@ -57,11 +33,6 @@ public static NegotiateAuthenticationPal Create(NegotiateAuthenticationClientOpt
5733 case NegotiationInfoClass . Negotiate :
5834 return new ManagedSpnegoNegotiateAuthenticationPal ( clientOptions , supportKerberos : true ) ;
5935 }
60-
61- if ( ! _isGssApiAvailable )
62- {
63- return new UnsupportedNegotiateAuthenticationPal ( clientOptions ) ;
64- }
6536 }
6637
6738 try
@@ -76,15 +47,15 @@ public static NegotiateAuthenticationPal Create(NegotiateAuthenticationClientOpt
7647 {
7748 return new UnsupportedNegotiateAuthenticationPal ( clientOptions ) ;
7849 }
50+ catch ( EntryPointNotFoundException )
51+ {
52+ // GSSAPI shim may not be available on some platforms (Linux Bionic)
53+ return new UnsupportedNegotiateAuthenticationPal ( clientOptions ) ;
54+ }
7955 }
8056
8157 public static NegotiateAuthenticationPal Create ( NegotiateAuthenticationServerOptions serverOptions )
8258 {
83- if ( ! _isGssApiAvailable )
84- {
85- return new UnsupportedNegotiateAuthenticationPal ( serverOptions ) ;
86- }
87-
8859 try
8960 {
9061 return new UnixNegotiateAuthenticationPal ( serverOptions ) ;
@@ -97,6 +68,11 @@ public static NegotiateAuthenticationPal Create(NegotiateAuthenticationServerOpt
9768 {
9869 return new UnsupportedNegotiateAuthenticationPal ( serverOptions ) ;
9970 }
71+ catch ( EntryPointNotFoundException )
72+ {
73+ // GSSAPI shim may not be available on some platforms (Linux Bionic)
74+ return new UnsupportedNegotiateAuthenticationPal ( serverOptions ) ;
75+ }
10076 }
10177
10278 internal sealed class UnixNegotiateAuthenticationPal : NegotiateAuthenticationPal
0 commit comments