Skip to content

Commit f684185

Browse files
Revert excluding unsupported protocols (#1824)
1 parent 1c03b1d commit f684185

File tree

7 files changed

+9
-42
lines changed

7 files changed

+9
-42
lines changed

BUILDGUIDE.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -321,12 +321,6 @@ Scaled decimal parameter truncation can be enabled by enabling the below AppCont
321321

322322
`Switch.Microsoft.Data.SqlClient.LegacyRowVersionNullBehavior`
323323

324-
## Enabling OS secure protocols preference
325-
326-
TLS 1.3 has been excluded due to the fact that the driver lacks full support. To enable OS preferences as before, enable the following AppContext switch on application startup:
327-
328-
`Switch.Microsoft.Data.SqlClient.EnableSecureProtocolsByOS`
329-
330324
## Suppressing TLS security warning
331325

332326
When connecting to a server, if a protocol lower than TLS 1.2 is negotiated, a security warning is output to the console. This warning can be suppressed on SQL connections with `Encrypt = false` by enabling the following AppContext switch on application startup:

src/Microsoft.Data.SqlClient/netcore/src/Interop/SNINativeMethodWrapper.Windows.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ internal struct SNI_Error
287287
private static extern uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapper.QTypes QType, out ProviderEnum provNum);
288288

289289
[DllImport(SNI, CallingConvention = CallingConvention.Cdecl)]
290-
private static extern uint SNIInitialize([In] bool useSystemDefaultSecureProtocols, [In] IntPtr pmo);
290+
private static extern uint SNIInitialize([In] IntPtr pmo);
291291

292292
[DllImport(SNI, CallingConvention = CallingConvention.Cdecl)]
293293
private static extern uint SNIOpenSyncExWrapper(ref SNI_CLIENT_CONSUMER_INFO pClientConsumerInfo, out IntPtr ppConn);
@@ -375,7 +375,7 @@ internal static uint SniGetConnectionIPString(SNIHandle pConn, ref string connIP
375375

376376
internal static uint SNIInitialize()
377377
{
378-
return SNIInitialize(LocalAppContextSwitches.UseSystemDefaultSecureProtocols, IntPtr.Zero);
378+
return SNIInitialize(IntPtr.Zero);
379379
}
380380

381381
internal static unsafe uint SNIOpenMarsSession(ConsumerInfo consumerInfo, SNIHandle parent, ref IntPtr pConn, bool fSync, SqlConnectionIPAddressPreference ipPreference, SQLDNSInfo cachedDNSInfo)

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIHandle.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,7 @@ namespace Microsoft.Data.SqlClient.SNI
1717
/// </summary>
1818
internal abstract class SNIHandle
1919
{
20-
/// <summary>
21-
/// Exclude TLS 1.3 in TLS-over-TDS modes (TDS 7.4 and below)
22-
/// </summary>
23-
protected static readonly SslProtocols s_supportedProtocols = LocalAppContextSwitches.UseSystemDefaultSecureProtocols ? SslProtocols.None : SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls
24-
//protected readonly SslProtocols SupportedProtocols = SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls
25-
#pragma warning disable CS0618 // Type or member is obsolete
26-
| SslProtocols.Ssl2 | SslProtocols.Ssl3
27-
#pragma warning restore CS0618 // Type or member is obsolete
28-
;
20+
protected static readonly SslProtocols s_supportedProtocols = SslProtocols.None;
2921

3022
#if !NETSTANDARD2_0
3123
protected static readonly List<SslApplicationProtocol> s_tdsProtocols = new List<SslApplicationProtocol>(1) { new(TdsEnums.TDS8_Protocol) };

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperX64.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ internal static class SNINativeManagedWrapperX64
8989
internal static extern uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapper.QTypes QType, out ProviderEnum provNum);
9090

9191
[DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIInitialize")]
92-
internal static extern uint SNIInitialize([In] bool useSystemDefaultSecureProtocols, [In] IntPtr pmo);
92+
internal static extern uint SNIInitialize([In] IntPtr pmo);
9393

9494
[DllImport(SNI, CallingConvention = CallingConvention.Cdecl)]
9595
internal static extern uint SNIOpenSyncExWrapper(ref SNI_CLIENT_CONSUMER_INFO pClientConsumerInfo, out IntPtr ppConn);

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeManagedWrapperX86.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ internal static class SNINativeManagedWrapperX86
8989
internal static extern uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapper.QTypes QType, out ProviderEnum provNum);
9090

9191
[DllImport(SNI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SNIInitialize")]
92-
internal static extern uint SNIInitialize([In] bool useSystemDefaultSecureProtocols, [In] IntPtr pmo);
92+
internal static extern uint SNIInitialize([In] IntPtr pmo);
9393

9494
[DllImport(SNI, CallingConvention = CallingConvention.Cdecl)]
9595
internal static extern uint SNIOpenSyncExWrapper(ref SNI_CLIENT_CONSUMER_INFO pClientConsumerInfo, out IntPtr ppConn);

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeMethodWrapper.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -593,11 +593,11 @@ private static uint SNIGetInfoWrapper([In] SNIHandle pConn, SNINativeMethodWrapp
593593
SNINativeManagedWrapperX86.SNIGetInfoWrapper(pConn, QType, out provNum);
594594
}
595595

596-
private static uint SNIInitialize([In] bool useSystemDefaultSecureProtocols, [In] IntPtr pmo)
596+
private static uint SNIInitialize([In] IntPtr pmo)
597597
{
598598
return s_is64bitProcess ?
599-
SNINativeManagedWrapperX64.SNIInitialize(useSystemDefaultSecureProtocols, pmo) :
600-
SNINativeManagedWrapperX86.SNIInitialize(useSystemDefaultSecureProtocols, pmo);
599+
SNINativeManagedWrapperX64.SNIInitialize(pmo) :
600+
SNINativeManagedWrapperX86.SNIInitialize(pmo);
601601
}
602602

603603
private static uint SNIOpenSyncExWrapper(ref SNI_CLIENT_CONSUMER_INFO pClientConsumerInfo, out IntPtr ppConn)
@@ -765,7 +765,7 @@ internal static uint SniGetConnectionIPString(SNIHandle pConn, ref string connIP
765765

766766
internal static uint SNIInitialize()
767767
{
768-
return SNIInitialize(LocalAppContextSwitches.UseSystemDefaultSecureProtocols, IntPtr.Zero);
768+
return SNIInitialize(IntPtr.Zero);
769769
}
770770

771771
internal static IntPtr SNIServerEnumOpen() => s_is64bitProcess ?

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalAppContextSwitches.cs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@ internal static partial class LocalAppContextSwitches
1313
private const string TypeName = nameof(LocalAppContextSwitches);
1414
internal const string MakeReadAsyncBlockingString = @"Switch.Microsoft.Data.SqlClient.MakeReadAsyncBlocking";
1515
internal const string LegacyRowVersionNullString = @"Switch.Microsoft.Data.SqlClient.LegacyRowVersionNullBehavior";
16-
internal const string UseSystemDefaultSecureProtocolsString = @"Switch.Microsoft.Data.SqlClient.UseSystemDefaultSecureProtocols";
1716
internal const string SuppressInsecureTLSWarningString = @"Switch.Microsoft.Data.SqlClient.SuppressInsecureTLSWarning";
1817

1918
private static bool s_makeReadAsyncBlocking;
2019
private static bool? s_LegacyRowVersionNullBehavior;
21-
private static bool? s_UseSystemDefaultSecureProtocols;
2220
private static bool? s_SuppressInsecureTLSWarning;
2321

2422
#if !NETFRAMEWORK
@@ -78,22 +76,5 @@ public static bool LegacyRowVersionNullBehavior
7876
return s_LegacyRowVersionNullBehavior.Value;
7977
}
8078
}
81-
82-
/// <summary>
83-
/// For backward compatibility, this switch can be on to jump back on OS preferences.
84-
/// </summary>
85-
public static bool UseSystemDefaultSecureProtocols
86-
{
87-
get
88-
{
89-
if (s_UseSystemDefaultSecureProtocols is null)
90-
{
91-
bool result;
92-
result = AppContext.TryGetSwitch(UseSystemDefaultSecureProtocolsString, out result) ? result : false;
93-
s_UseSystemDefaultSecureProtocols = result;
94-
}
95-
return s_UseSystemDefaultSecureProtocols.Value;
96-
}
97-
}
9879
}
9980
}

0 commit comments

Comments
 (0)