From f03963e19badd99695a52f03d3502520478246a1 Mon Sep 17 00:00:00 2001 From: JRahnama Date: Wed, 11 May 2022 09:47:07 -0700 Subject: [PATCH 1/3] Review comments --- .../src/Microsoft/Data/SqlClient/SNI/SNINpHandle.cs | 5 ++--- .../src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs | 12 ++++++------ .../src/Microsoft/Data/SqlClient/TdsParser.cs | 2 +- .../netfx/src/Microsoft/Data/SqlClient/TdsParser.cs | 4 ++-- .../Data/SqlClient/TdsParserHelperClasses.cs | 2 +- .../src/Microsoft/Data/SqlClient/TdsEnums.cs | 2 +- 6 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNINpHandle.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNINpHandle.cs index 441569cbba..3bd8cadff2 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNINpHandle.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNINpHandle.cs @@ -324,13 +324,12 @@ public override uint EnableSsl(uint options) { if (_isTDS8) { -#if NETCOREAPP - SslApplicationProtocol TDS8 = new("tds/8.0"); +#if NETCOREAPP SslClientAuthenticationOptions sslClientOptions = new() { TargetHost = _serverNameIndication, - ApplicationProtocols = new List() { TDS8 }, + ApplicationProtocols = new List(5) { new(TdsEnums.s_tDS8Protocol) }, EnabledSslProtocols = SupportedProtocols, ClientCertificates = null, }; diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs index 4b03b23531..5fd7ede7a8 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs @@ -28,7 +28,7 @@ internal sealed class SNITCPHandle : SNIPhysicalHandle private NetworkStream _tcpStream; private readonly string _hostNameInCertificate; private readonly bool _isTDSS; - private readonly string _serverIndicationName; + private readonly string _serverNameIndication; private Stream _stream; private SslStream _sslStream; @@ -133,7 +133,7 @@ public SNITCPHandle(string serverName, int port, long timerExpire, bool parallel _targetServer = serverName; _isTDSS = isTDSS; _hostNameInCertificate = hostNameInCertificate; - _serverIndicationName = serverNameIndication; + _serverNameIndication = serverNameIndication; _sendSync = new object(); SQLDNSInfo cachedDNSInfo; @@ -604,8 +604,8 @@ public override uint EnableSsl(uint options) SslClientAuthenticationOptions sslClientOptions = new() { - TargetHost = _serverIndicationName, - ApplicationProtocols = new List() { new(TdsEnums.TDS8) }, + TargetHost = _serverNameIndication, + ApplicationProtocols = new List(5) { new(TdsEnums.s_tDS8Protocol) }, EnabledSslProtocols = SupportedProtocols, ClientCertificates = null, }; @@ -614,7 +614,7 @@ public override uint EnableSsl(uint options) } else { - _sslStream.AuthenticateAsClient(_serverIndicationName, null, SupportedProtocols, false); + _sslStream.AuthenticateAsClient(_serverNameIndication, null, SupportedProtocols, false); } if (_sslOverTdsStream is not null) { @@ -676,7 +676,7 @@ private bool ValidateServerCertificate(object sender, X509Certificate cert, X509 } else { - serverNameToValidate = _hostNameInCertificate; + serverNameToValidate = _targetServer; } SqlClientEventSource.Log.TrySNITraceEvent(nameof(SNITCPHandle), EventType.INFO, "Connection Id {0}, Certificate will be validated for Target Server name", args0: _connectionId); diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs index 3921f8951d..5f25face87 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs @@ -414,7 +414,7 @@ internal void Connect( SqlClientEventSource.Log.TryTraceEvent("TdsParser.Connect | SEC | SSPI or Active Directory Authentication Library loaded for SQL Server based integrated authentication"); } - // if Strict encryotion is chosen TDS8 should be used and trust server certificate should be false. + // if Strict encryption is chosen TDS8 should be used and trust server certificate should be false. if (encrypt == SqlConnectionEncryptionOption.Strict) { isTDS8 = true; diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs index ada0d41f6e..3693c1d0d0 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs @@ -673,7 +673,7 @@ internal void Connect(ServerInfo serverInfo, // UNDONE - send "" for instance now, need to fix later SqlClientEventSource.Log.TryTraceEvent(" Sending prelogin handshake"); - SendPreLoginHandshake(instanceName, encrypt, isTDS8!, string.IsNullOrEmpty(certificate), useOriginalAddressInfo); + SendPreLoginHandshake(instanceName, encrypt, isTDS8, !string.IsNullOrEmpty(certificate), useOriginalAddressInfo); _connHandler.TimeoutErrorInternal.EndPhase(SqlConnectionTimeoutErrorPhase.SendPreLoginHandshake); _connHandler.TimeoutErrorInternal.SetAndBeginPhase(SqlConnectionTimeoutErrorPhase.ConsumePreLoginHandshake); @@ -1257,7 +1257,7 @@ private PreLoginHandshakeStatus ConsumePreLoginHandshake(SqlAuthenticationMethod // NOT_SUP: No encryption. break; - case (EncryptionOptions.Strict): + case (EncryptionOptions.STRICT): if ((serverOption & EncryptionOptions.OPTIONS_MASK) == EncryptionOptions.REQ) { _physicalStateObj.AddError(new SqlError(TdsEnums.ENCRYPTION_NOT_SUPPORTED, (byte)0x00, TdsEnums.FATAL_ERROR_CLASS, _server, SQLMessage.EncryptionNotSupportedByClient(), "", 0)); diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs index 044a9dfc5c..4b17558b2b 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs @@ -29,7 +29,7 @@ internal enum EncryptionOptions NOT_SUP, REQ, LOGIN, - Strict, //TDS8 + STRICT, //TDS8 OPTIONS_MASK = 0x3f, CTAIP = 0x40, CLIENT_CERT = 0x80, diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsEnums.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsEnums.cs index 596d4b7b1e..213f100d34 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsEnums.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsEnums.cs @@ -345,7 +345,7 @@ public enum ActiveDirectoryWorkflow : byte public const int SQL2005_MAJOR = 0x72; // the high-byte is sufficient to distinguish later versions public const int SQL2008_MAJOR = 0x73; public const int SQL2012_MAJOR = 0x74; - public const string TDS8 = "tds/8.0"; //TDS8 + public static string s_tDS8Protocol = "tds/8.0"; //TDS8 // Increments: public const int SQL2000SP1_INCREMENT = 0x00; From e58fc339c0b30dcdbe99a835b36d9ffd7d5ee51d Mon Sep 17 00:00:00 2001 From: Javad Date: Wed, 11 May 2022 12:32:03 -0700 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: David Engel --- .../SqlConnectionEncryptionOption.xml | 3 +-- .../src/Microsoft/Data/SqlClient/SNI/SNIProxy.cs | 3 +-- .../src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs | 12 ++++++------ 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlConnectionEncryptionOption.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlConnectionEncryptionOption.xml index e70ce78062..0a1184a56d 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlConnectionEncryptionOption.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlConnectionEncryptionOption.xml @@ -3,8 +3,7 @@ - - Note that these settings cannot be used to bypass encryption and gain access to plaintext data. For details, see Always Encrypted (Database Engine). + These options are used to control encryption behavior of the communication between the server and the client.. To be added. diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIProxy.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIProxy.cs index 13d10f8106..c918787486 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIProxy.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIProxy.cs @@ -20,7 +20,6 @@ internal class SNIProxy { private const int DefaultSqlServerPort = 1433; private const int DefaultSqlServerDacPort = 1434; - private const int DefaultSqlServerTDS8Port = 4433; private const string SqlServerSpnHeader = "MSSQLSvc"; private const string TDS8SNIServerKey = "Server"; private const string TDS8SNIInstanceKey = "Instance"; @@ -336,7 +335,7 @@ private static SNITCPHandle CreateTcpHandle(DataSource details, long timerExpire } else { - port = isAdminConnection ? DefaultSqlServerDacPort : (isTDS8 ? DefaultSqlServerTDS8Port : DefaultSqlServerPort); + port = isAdminConnection ? DefaultSqlServerDacPort : DefaultSqlServerPort; } return new SNITCPHandle(hostName, port, timerExpire, parallel, ipPreference, cachedFQDN, ref pendingDNSInfo, isTDS8, hostNameInCertificate, serverNameIndication); diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs index 5fd7ede7a8..947e5f3734 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs @@ -27,7 +27,7 @@ internal sealed class SNITCPHandle : SNIPhysicalHandle private readonly Socket _socket; private NetworkStream _tcpStream; private readonly string _hostNameInCertificate; - private readonly bool _isTDSS; + private readonly bool _isTDS8; private readonly string _serverNameIndication; private Stream _stream; @@ -121,17 +121,17 @@ public override int ProtocolVersion /// IP address preference /// Key for DNS Cache /// Used for DNS Cache - /// Support TDS8.0 + /// Support TDS8.0 /// Host Name in Certoficate /// - public SNITCPHandle(string serverName, int port, long timerExpire, bool parallel, SqlConnectionIPAddressPreference ipPreference, string cachedFQDN, ref SQLDNSInfo pendingDNSInfo, bool isTDSS, string hostNameInCertificate, string serverNameIndication) + public SNITCPHandle(string serverName, int port, long timerExpire, bool parallel, SqlConnectionIPAddressPreference ipPreference, string cachedFQDN, ref SQLDNSInfo pendingDNSInfo, bool isTDS8, string hostNameInCertificate, string serverNameIndication) { using (TrySNIEventScope.Create(nameof(SNITCPHandle))) { SqlClientEventSource.Log.TrySNITraceEvent(nameof(SNITCPHandle), EventType.INFO, "Connection Id {0}, Setting server name = {1}", args0: _connectionId, args1: serverName); _targetServer = serverName; - _isTDSS = isTDSS; + _isTDS8 = isTDS8; _hostNameInCertificate = hostNameInCertificate; _serverNameIndication = serverNameIndication; _sendSync = new object(); @@ -259,7 +259,7 @@ public SNITCPHandle(string serverName, int port, long timerExpire, bool parallel _tcpStream = new SNINetworkStream(_socket, true); Stream stream = _tcpStream; - if (!_isTDSS) + if (!_isTDS8) { _sslOverTdsStream = new SslOverTdsStream(_tcpStream, _connectionId); stream = _sslOverTdsStream; @@ -598,7 +598,7 @@ public override uint EnableSsl(uint options) try { - if (_isTDSS) + if (_isTDS8) { #if NETCOREAPP From 5ca4234d1216e1896cef3f13956a1b351cfe87f3 Mon Sep 17 00:00:00 2001 From: JRahnama Date: Wed, 11 May 2022 09:47:07 -0700 Subject: [PATCH 3/3] Review comments --- .../Microsoft/Data/SqlClient/SNI/SNIHandle.cs | 23 ++++++++++++++++++- .../Data/SqlClient/SNI/SNINpHandle.cs | 16 +++---------- .../Data/SqlClient/SNI/SNIPhysicalHandle.cs | 3 ++- .../Data/SqlClient/SNI/SNITcpHandle.cs | 20 +++++----------- .../src/Microsoft/Data/SqlClient/TdsParser.cs | 2 +- .../src/Microsoft/Data/SqlClient/TdsParser.cs | 4 ++-- .../Data/SqlClient/TdsParserHelperClasses.cs | 2 +- .../src/Microsoft/Data/SqlClient/TdsEnums.cs | 4 ++-- 8 files changed, 39 insertions(+), 35 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIHandle.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIHandle.cs index dbee403f41..06b5daa701 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIHandle.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIHandle.cs @@ -3,7 +3,12 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; +using System.Net.Security; using System.Security.Authentication; +using System.Security.Cryptography.X509Certificates; +using System.Threading; +using System.Threading.Tasks; namespace Microsoft.Data.SqlClient.SNI { @@ -15,13 +20,29 @@ internal abstract class SNIHandle /// /// Exclude TLS 1.3 (not fully supported). /// - protected readonly SslProtocols SupportedProtocols = LocalAppContextSwitches.UseSystemDefaultSecureProtocols ? SslProtocols.None : SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls + protected static readonly SslProtocols s_supportedProtocols = LocalAppContextSwitches.UseSystemDefaultSecureProtocols ? SslProtocols.None : SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls //protected readonly SslProtocols SupportedProtocols = SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls #pragma warning disable CS0618 // Type or member is obsolete | SslProtocols.Ssl2 | SslProtocols.Ssl3 #pragma warning restore CS0618 // Type or member is obsolete ; +#if !NETSTANDARD2_0 + protected static readonly List s_tdsProtocols = new List(7) { new(TdsEnums.TDS8_Protocol) }; + + protected static async Task AuthenticateClientAsync(SslStream sslStream, string serverNameIndication, X509CertificateCollection certificate) + { + SslClientAuthenticationOptions sslClientOptions = new() + { + TargetHost = serverNameIndication, + ApplicationProtocols = s_tdsProtocols, + EnabledSslProtocols = s_supportedProtocols, + ClientCertificates = certificate + }; + await sslStream.AuthenticateAsClientAsync(sslClientOptions, CancellationToken.None); + } +#endif + /// /// Dispose class /// diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNINpHandle.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNINpHandle.cs index 441569cbba..a228d81eba 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNINpHandle.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNINpHandle.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.ComponentModel; using System.IO; using System.IO.Pipes; @@ -324,22 +323,13 @@ public override uint EnableSsl(uint options) { if (_isTDS8) { -#if NETCOREAPP - SslApplicationProtocol TDS8 = new("tds/8.0"); - - SslClientAuthenticationOptions sslClientOptions = new() - { - TargetHost = _serverNameIndication, - ApplicationProtocols = new List() { TDS8 }, - EnabledSslProtocols = SupportedProtocols, - ClientCertificates = null, - }; - _sslStream.AuthenticateAsClientAsync(sslClientOptions).Wait(); +#if !NETSTANDARD2_0 + AuthenticateClientAsync(_sslStream, _serverNameIndication, null); #endif } else { - _sslStream.AuthenticateAsClient(_targetServer, null, SupportedProtocols, false); + _sslStream.AuthenticateAsClient(_targetServer, null, s_supportedProtocols, false); } if (_sslOverTdsStream is not null) { diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIPhysicalHandle.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIPhysicalHandle.cs index ba08f99bea..94f37d0c6a 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIPhysicalHandle.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIPhysicalHandle.cs @@ -12,6 +12,7 @@ namespace Microsoft.Data.SqlClient.SNI internal abstract class SNIPhysicalHandle : SNIHandle { protected const int DefaultPoolSize = 4; + #if DEBUG private static int s_packetId; #endif @@ -84,7 +85,7 @@ private string GetStackParts() { return string.Join(Environment.NewLine, Environment.StackTrace - .Split(new string[] { Environment.NewLine },StringSplitOptions.None) + .Split(new string[] { Environment.NewLine }, StringSplitOptions.None) .Skip(3) // trims off the common parts at the top of the stack so you can see what the actual caller was .Take(7) // trims off most of the bottom of the stack because when running under xunit there's a lot of spam ); diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs index 4b03b23531..c771e44a7e 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs @@ -28,7 +28,7 @@ internal sealed class SNITCPHandle : SNIPhysicalHandle private NetworkStream _tcpStream; private readonly string _hostNameInCertificate; private readonly bool _isTDSS; - private readonly string _serverIndicationName; + private readonly string _serverNameIndication; private Stream _stream; private SslStream _sslStream; @@ -133,7 +133,7 @@ public SNITCPHandle(string serverName, int port, long timerExpire, bool parallel _targetServer = serverName; _isTDSS = isTDSS; _hostNameInCertificate = hostNameInCertificate; - _serverIndicationName = serverNameIndication; + _serverNameIndication = serverNameIndication; _sendSync = new object(); SQLDNSInfo cachedDNSInfo; @@ -600,21 +600,13 @@ public override uint EnableSsl(uint options) { if (_isTDSS) { -#if NETCOREAPP - - SslClientAuthenticationOptions sslClientOptions = new() - { - TargetHost = _serverIndicationName, - ApplicationProtocols = new List() { new(TdsEnums.TDS8) }, - EnabledSslProtocols = SupportedProtocols, - ClientCertificates = null, - }; - _sslStream.AuthenticateAsClientAsync(sslClientOptions).Wait(); +#if !NETSTANDARD2_0 + AuthenticateClientAsync(_sslStream, _serverNameIndication, null).Wait(); #endif } else { - _sslStream.AuthenticateAsClient(_serverIndicationName, null, SupportedProtocols, false); + _sslStream.AuthenticateAsClient(_serverNameIndication, null, s_supportedProtocols, false); } if (_sslOverTdsStream is not null) { @@ -676,7 +668,7 @@ private bool ValidateServerCertificate(object sender, X509Certificate cert, X509 } else { - serverNameToValidate = _hostNameInCertificate; + serverNameToValidate = _targetServer; } SqlClientEventSource.Log.TrySNITraceEvent(nameof(SNITCPHandle), EventType.INFO, "Connection Id {0}, Certificate will be validated for Target Server name", args0: _connectionId); diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs index 3921f8951d..5f25face87 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs @@ -414,7 +414,7 @@ internal void Connect( SqlClientEventSource.Log.TryTraceEvent("TdsParser.Connect | SEC | SSPI or Active Directory Authentication Library loaded for SQL Server based integrated authentication"); } - // if Strict encryotion is chosen TDS8 should be used and trust server certificate should be false. + // if Strict encryption is chosen TDS8 should be used and trust server certificate should be false. if (encrypt == SqlConnectionEncryptionOption.Strict) { isTDS8 = true; diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs index ada0d41f6e..3693c1d0d0 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs @@ -673,7 +673,7 @@ internal void Connect(ServerInfo serverInfo, // UNDONE - send "" for instance now, need to fix later SqlClientEventSource.Log.TryTraceEvent(" Sending prelogin handshake"); - SendPreLoginHandshake(instanceName, encrypt, isTDS8!, string.IsNullOrEmpty(certificate), useOriginalAddressInfo); + SendPreLoginHandshake(instanceName, encrypt, isTDS8, !string.IsNullOrEmpty(certificate), useOriginalAddressInfo); _connHandler.TimeoutErrorInternal.EndPhase(SqlConnectionTimeoutErrorPhase.SendPreLoginHandshake); _connHandler.TimeoutErrorInternal.SetAndBeginPhase(SqlConnectionTimeoutErrorPhase.ConsumePreLoginHandshake); @@ -1257,7 +1257,7 @@ private PreLoginHandshakeStatus ConsumePreLoginHandshake(SqlAuthenticationMethod // NOT_SUP: No encryption. break; - case (EncryptionOptions.Strict): + case (EncryptionOptions.STRICT): if ((serverOption & EncryptionOptions.OPTIONS_MASK) == EncryptionOptions.REQ) { _physicalStateObj.AddError(new SqlError(TdsEnums.ENCRYPTION_NOT_SUPPORTED, (byte)0x00, TdsEnums.FATAL_ERROR_CLASS, _server, SQLMessage.EncryptionNotSupportedByClient(), "", 0)); diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs index 044a9dfc5c..4b17558b2b 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs @@ -29,7 +29,7 @@ internal enum EncryptionOptions NOT_SUP, REQ, LOGIN, - Strict, //TDS8 + STRICT, //TDS8 OPTIONS_MASK = 0x3f, CTAIP = 0x40, CLIENT_CERT = 0x80, diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsEnums.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsEnums.cs index 596d4b7b1e..d8cfed40a9 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsEnums.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsEnums.cs @@ -345,7 +345,7 @@ public enum ActiveDirectoryWorkflow : byte public const int SQL2005_MAJOR = 0x72; // the high-byte is sufficient to distinguish later versions public const int SQL2008_MAJOR = 0x73; public const int SQL2012_MAJOR = 0x74; - public const string TDS8 = "tds/8.0"; //TDS8 + public const string TDS8_Protocol = "tds/8.0"; //TDS8 // Increments: public const int SQL2000SP1_INCREMENT = 0x00; @@ -1121,7 +1121,7 @@ public enum SqlConnectionAttestationProtocol public enum SqlConnectionEncryptionOption { /// - Optional =0, + Optional = 0, /// Mandatory = 1, ///