1 //------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //------------------------------------------------------------
5 #pragma warning disable 0436 //Disable the type conflict warning for the types used by LocalAppContext framework (Quirking)
6 namespace System.IdentityModel
9 using System.Runtime.CompilerServices;
11 // When adding a quirk, name it such that false is new behavior and true is old behavior.
12 // You are opting IN to old behavior. The new behavior is default.
13 // For example, we want to enable the functionality to explicitly add a connection close header
14 // in 4.6 and above. So we set DisableExplicitConnectionCloseHeader to true if running 4.5.2 or less.
15 internal static class LocalAppContextSwitches
17 private const string EnableCachedEmptyDefaultAuthorizationContextString = "Switch.System.IdentityModel.EnableCachedEmptyDefaultAuthorizationContext";
18 private const string DisableMultipleDNSEntriesInSANCertificateString = "Switch.System.IdentityModel.DisableMultipleDNSEntriesInSANCertificate";
19 private const string DisableUpdatingRsaProviderTypeString = "Switch.System.IdentityModel.DisableUpdatingRsaProviderType";
20 private const string DisableCngCertificatesString = "Switch.System.IdentityModel.DisableCngCertificates";
22 private static int enableCachedEmptyDefaultAuthorizationContext;
23 private static int disableMultipleDNSEntriesInSANCertificate;
24 private static int disableUpdatingRsaProviderType;
25 private static int disableCngCertificatesString;
27 public static bool EnableCachedEmptyDefaultAuthorizationContext
29 [MethodImpl(MethodImplOptions.AggressiveInlining)]
32 return LocalAppContext.GetCachedSwitchValue(EnableCachedEmptyDefaultAuthorizationContextString, ref enableCachedEmptyDefaultAuthorizationContext);
36 public static bool DisableMultipleDNSEntriesInSANCertificate
38 [MethodImpl(MethodImplOptions.AggressiveInlining)]
41 return LocalAppContext.GetCachedSwitchValue(DisableMultipleDNSEntriesInSANCertificateString, ref disableMultipleDNSEntriesInSANCertificate);
45 public static bool DisableUpdatingRsaProviderType
47 [MethodImpl(MethodImplOptions.AggressiveInlining)]
50 return LocalAppContext.GetCachedSwitchValue(DisableUpdatingRsaProviderTypeString, ref disableUpdatingRsaProviderType);
54 public static bool DisableCngCertificates
56 [MethodImpl(MethodImplOptions.AggressiveInlining)]
59 return LocalAppContext.GetCachedSwitchValue(DisableCngCertificatesString, ref disableCngCertificatesString);
63 public static void SetDefaultsLessOrEqual_452()
65 #pragma warning disable BCL0012
66 // Define the switches that should be true for 4.5.2 or less, false for 4.6+.
67 LocalAppContext.DefineSwitchDefault(EnableCachedEmptyDefaultAuthorizationContextString, true);
68 #pragma warning restore BCL0012
71 public static void SetDefaultsLessOrEqual_46()
73 #pragma warning disable BCL0012
74 // Define the switches that should be true for 4.6 or less, false for 4.6.1+.
75 LocalAppContext.DefineSwitchDefault(DisableMultipleDNSEntriesInSANCertificateString, true);
76 #pragma warning restore BCL0012
79 public static void SetDefaultsLessOrEqual_462()
81 #pragma warning disable BCL0012
82 // Define the switches that should be true for 4.6.2 or less, false for above 4.6.2.
83 LocalAppContext.DefineSwitchDefault(DisableCngCertificatesString, true);
84 #pragma warning restore BCL0012