diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj index d1dd14f6b7..f52e488239 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj @@ -958,7 +958,6 @@ Microsoft\Data\SqlTypes\SqlFileStream.Windows.cs - @@ -1006,8 +1005,6 @@ Microsoft\Data\SqlTypes\SqlFileStream.netcore.Unix.cs - - ILLink.Substitutions.xml Resources\ILLink.Substitutions.Unix.xml diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.Unix.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.Unix.cs deleted file mode 100644 index c993df824c..0000000000 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.Unix.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Data.SqlClient.ManagedSni; - -namespace Microsoft.Data.SqlClient -{ - sealed internal partial class TdsParser - { - internal void PostReadAsyncForMars() - { - // No-Op - } - - private void LoadSSPILibrary() - { - // No - Op - } - - private void WaitForSSLHandShakeToComplete(ref uint error, ref int protocolVersion) - { - // No - Op - } - } -} diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.Windows.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.Windows.cs deleted file mode 100644 index 8074fda5a7..0000000000 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.Windows.cs +++ /dev/null @@ -1,63 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Diagnostics; - -namespace Microsoft.Data.SqlClient -{ - internal sealed partial class TdsParser - { - internal void PostReadAsyncForMars() - { - if (LocalAppContextSwitches.UseManagedNetworking) - return; - - // HACK HACK HACK - for Async only - // Have to post read to initialize MARS - will get callback on this when connection goes - // down or is closed. - - PacketHandle temp = default; - uint error = TdsEnums.SNI_SUCCESS; - - _pMarsPhysicalConObj.IncrementPendingCallbacks(); - SessionHandle handle = _pMarsPhysicalConObj.SessionHandle; - // we do not need to consider partial packets when making this read because we - // expect this read to pend. a partial packet should not exist at setup of the - // parser - Debug.Assert(_physicalStateObj.PartialPacket==null); - temp = _pMarsPhysicalConObj.ReadAsync(handle, out error); - - Debug.Assert(temp.Type == PacketHandle.NativePointerType, "unexpected packet type when requiring NativePointer"); - - if (temp.NativePointer != IntPtr.Zero) - { - // Be sure to release packet, otherwise it will be leaked by native. - _pMarsPhysicalConObj.ReleasePacket(temp); - } - - Debug.Assert(IntPtr.Zero == temp.NativePointer, "unexpected syncReadPacket without corresponding SNIPacketRelease"); - if (TdsEnums.SNI_SUCCESS_IO_PENDING != error) - { - Debug.Assert(TdsEnums.SNI_SUCCESS != error, "Unexpected successful read async on physical connection before enabling MARS!"); - _physicalStateObj.AddError(ProcessSNIError(_physicalStateObj)); - ThrowExceptionAndWarning(_physicalStateObj); - } - } - - private void WaitForSSLHandShakeToComplete(ref uint error, ref int protocolVersion) - { - // in the case where an async connection is made, encryption is used and Windows Authentication is used, - // wait for SSL handshake to complete, so that the SSL context is fully negotiated before we try to use its - // Channel Bindings as part of the Windows Authentication context build (SSL handshake must complete - // before calling SNISecGenClientContext). - error = _physicalStateObj.WaitForSSLHandShakeToComplete(out protocolVersion); - if (error != TdsEnums.SNI_SUCCESS) - { - _physicalStateObj.AddError(ProcessSNIError(_physicalStateObj)); - ThrowExceptionAndWarning(_physicalStateObj); - } - } - } // tdsparser -}//namespace 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 8480409042..8bb547497a 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 @@ -11,9 +11,8 @@ using System.Diagnostics; using System.Globalization; using System.IO; -#if NET using System.Security.Authentication; -#else +#if NETFRAMEWORK using System.Runtime.CompilerServices; #endif using System.Text; @@ -632,7 +631,13 @@ internal void EnableMars() ThrowExceptionAndWarning(_physicalStateObj); } - PostReadAsyncForMars(); + error = _pMarsPhysicalConObj.PostReadAsyncForMars(_physicalStateObj); + if (error != TdsEnums.SNI_SUCCESS_IO_PENDING) + { + Debug.Assert(error != TdsEnums.SNI_SUCCESS, "Unexpected successful read async on physical connection before enabling MARS!"); + _physicalStateObj.AddError(ProcessSNIError(_physicalStateObj)); + ThrowExceptionAndWarning(_physicalStateObj); + } _physicalStateObj = CreateSession(); // Create and open default MARS stateObj and connection. } @@ -888,10 +893,24 @@ private void EnableSsl(uint info, SqlConnectionEncryptOption encrypt, bool integ ThrowExceptionAndWarning(_physicalStateObj); } - int protocolVersion = 0; - WaitForSSLHandShakeToComplete(ref error, ref protocolVersion); + SslProtocols protocol = 0; + + // in the case where an async connection is made, encryption is used and Windows Authentication is used, + // wait for SSL handshake to complete, so that the SSL context is fully negotiated before we try to use its + // Channel Bindings as part of the Windows Authentication context build (SSL handshake must complete + // before calling SNISecGenClientContext). +#if NET + if (OperatingSystem.IsWindows()) +#endif + { + error = _physicalStateObj.WaitForSSLHandShakeToComplete(out protocol); + if (error != TdsEnums.SNI_SUCCESS) + { + _physicalStateObj.AddError(ProcessSNIError(_physicalStateObj)); + ThrowExceptionAndWarning(_physicalStateObj); + } + } - SslProtocols protocol = (SslProtocols)protocolVersion; string warningMessage = protocol.GetProtocolWarning(); if (!string.IsNullOrEmpty(warningMessage)) { diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserStateObject.netcore.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserStateObject.netcore.cs index d7dc8b62f4..b802689b24 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserStateObject.netcore.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserStateObject.netcore.cs @@ -93,8 +93,6 @@ internal abstract void CreatePhysicalSNIHandle( internal abstract uint EnableSsl(ref uint info, bool tlsFirst, string serverCertificateFilename); - internal abstract uint WaitForSSLHandShakeToComplete(out int protocolVersion); - internal abstract void Dispose(); internal abstract uint CheckConnection(); diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserStateObjectManaged.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserStateObjectManaged.cs index ef4523eafd..2b173fb087 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserStateObjectManaged.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserStateObjectManaged.cs @@ -8,6 +8,7 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; +using System.Security.Authentication; using System.Threading; using System.Threading.Tasks; using Microsoft.Data.Common; @@ -365,6 +366,8 @@ internal override uint EnableMars(ref uint info) return TdsEnums.SNI_ERROR; } + internal override uint PostReadAsyncForMars(TdsParserStateObject physicalStateObject) => TdsEnums.SNI_SUCCESS_IO_PENDING; + internal override uint EnableSsl(ref uint info, bool tlsFirst, string serverCertificateFilename) { SniHandle sessionHandle = GetSessionSNIHandleHandleOrThrow(); @@ -386,10 +389,10 @@ internal override uint SetConnectionBufferSize(ref uint unsignedPacketSize) return TdsEnums.SNI_SUCCESS; } - internal override uint WaitForSSLHandShakeToComplete(out int protocolVersion) + internal override uint WaitForSSLHandShakeToComplete(out SslProtocols protocolVersion) { protocolVersion = GetSessionSNIHandleHandleOrThrow().ProtocolVersion; - return 0; + return TdsEnums.SNI_SUCCESS; } internal override SniErrorDetails GetErrorDetails() diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserStateObjectNative.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserStateObjectNative.cs index 4f2ccaab83..6f3bdb915a 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserStateObjectNative.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserStateObjectNative.cs @@ -385,6 +385,43 @@ internal override uint DisableSsl() internal override uint EnableMars(ref uint info) => SniNativeWrapper.SniAddProvider(Handle, Provider.SMUX_PROV, ref info); + internal override uint PostReadAsyncForMars(TdsParserStateObject physicalStateObject) + { + // HACK HACK HACK - for Async only + // Have to post read to initialize MARS - will get callback on this when connection goes + // down or is closed. + + PacketHandle temp = default; + uint error = TdsEnums.SNI_SUCCESS; + +#if NETFRAMEWORK + RuntimeHelpers.PrepareConstrainedRegions(); +#endif + try + { } + finally + { + IncrementPendingCallbacks(); + SessionHandle handle = SessionHandle; + // we do not need to consider partial packets when making this read because we + // expect this read to pend. a partial packet should not exist at setup of the + // parser + Debug.Assert(physicalStateObject.PartialPacket == null); + temp = ReadAsync(handle, out error); + + Debug.Assert(temp.Type == PacketHandle.NativePointerType, "unexpected packet type when requiring NativePointer"); + + if (temp.NativePointer != IntPtr.Zero) + { + // Be sure to release packet, otherwise it will be leaked by native. + ReleasePacket(temp); + } + } + + Debug.Assert(IntPtr.Zero == temp.NativePointer, "unexpected syncReadPacket without corresponding SNIPacketRelease"); + return error; + } + internal override uint EnableSsl(ref uint info, bool tlsFirst, string serverCertificateFilename) { AuthProviderInfo authInfo = new AuthProviderInfo(); @@ -399,7 +436,7 @@ internal override uint EnableSsl(ref uint info, bool tlsFirst, string serverCert internal override uint SetConnectionBufferSize(ref uint unsignedPacketSize) => SniNativeWrapper.SniSetInfo(Handle, QueryType.SNI_QUERY_CONN_BUFSIZE, ref unsignedPacketSize); - internal override uint WaitForSSLHandShakeToComplete(out int protocolVersion) + internal override uint WaitForSSLHandShakeToComplete(out SslProtocols protocolVersion) { uint returnValue = SniNativeWrapper.SniWaitForSslHandshakeToComplete(Handle, GetTimeoutRemaining(), out uint nativeProtocolVersion); var nativeProtocol = (NativeProtocols)nativeProtocolVersion; @@ -407,35 +444,35 @@ internal override uint WaitForSSLHandShakeToComplete(out int protocolVersion) #pragma warning disable CA5398 // Avoid hardcoded SslProtocols values if (nativeProtocol.HasFlag(NativeProtocols.SP_PROT_TLS1_2_CLIENT) || nativeProtocol.HasFlag(NativeProtocols.SP_PROT_TLS1_2_SERVER)) { - protocolVersion = (int)SslProtocols.Tls12; + protocolVersion = SslProtocols.Tls12; } else if (nativeProtocol.HasFlag(NativeProtocols.SP_PROT_TLS1_3_CLIENT) || nativeProtocol.HasFlag(NativeProtocols.SP_PROT_TLS1_3_SERVER)) { /* The SslProtocols.Tls13 is supported by netcoreapp3.1 and later */ - protocolVersion = (int)SslProtocols.Tls13; + protocolVersion = SslProtocols.Tls13; } else if (nativeProtocol.HasFlag(NativeProtocols.SP_PROT_TLS1_1_CLIENT) || nativeProtocol.HasFlag(NativeProtocols.SP_PROT_TLS1_1_SERVER)) { - protocolVersion = (int)SslProtocols.Tls11; + protocolVersion = SslProtocols.Tls11; } else if (nativeProtocol.HasFlag(NativeProtocols.SP_PROT_TLS1_0_CLIENT) || nativeProtocol.HasFlag(NativeProtocols.SP_PROT_TLS1_0_SERVER)) { - protocolVersion = (int)SslProtocols.Tls; + protocolVersion = SslProtocols.Tls; } else if (nativeProtocol.HasFlag(NativeProtocols.SP_PROT_SSL3_CLIENT) || nativeProtocol.HasFlag(NativeProtocols.SP_PROT_SSL3_SERVER)) { // SSL 2.0 and 3.0 are only referenced to log a warning, not explicitly used for connections #pragma warning disable CS0618, CA5397 - protocolVersion = (int)SslProtocols.Ssl3; + protocolVersion = SslProtocols.Ssl3; } else if (nativeProtocol.HasFlag(NativeProtocols.SP_PROT_SSL2_CLIENT) || nativeProtocol.HasFlag(NativeProtocols.SP_PROT_SSL2_SERVER)) { - protocolVersion = (int)SslProtocols.Ssl2; + protocolVersion = SslProtocols.Ssl2; #pragma warning restore CS0618, CA5397 } else //if (nativeProtocol.HasFlag(NativeProtocols.SP_PROT_NONE)) { - protocolVersion = (int)SslProtocols.None; + protocolVersion = SslProtocols.None; } #pragma warning restore CA5398 // Avoid hardcoded SslProtocols values return returnValue; 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 3ad9c84e78..7aafe80082 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 @@ -11,9 +11,8 @@ using System.Diagnostics; using System.Globalization; using System.IO; -#if NET using System.Security.Authentication; -#else +#if NETFRAMEWORK using System.Runtime.CompilerServices; #endif using System.Text; @@ -683,31 +682,10 @@ internal void EnableMars() ThrowExceptionAndWarning(_physicalStateObj); } - // HACK HACK HACK - for Async only - // Have to post read to intialize MARS - will get callback on this when connection goes - // down or is closed. - - IntPtr temp = IntPtr.Zero; - - RuntimeHelpers.PrepareConstrainedRegions(); - try - { } - finally - { - _pMarsPhysicalConObj.IncrementPendingCallbacks(); - - error = SniNativeWrapper.SniReadAsync(_pMarsPhysicalConObj.Handle, ref temp); - - if (temp != IntPtr.Zero) - { - // Be sure to release packet, otherwise it will be leaked by native. - SniNativeWrapper.SniPacketRelease(temp); - } - } - Debug.Assert(IntPtr.Zero == temp, "unexpected syncReadPacket without corresponding SNIPacketRelease"); - if (TdsEnums.SNI_SUCCESS_IO_PENDING != error) + error = _pMarsPhysicalConObj.PostReadAsyncForMars(_physicalStateObj); + if (error != TdsEnums.SNI_SUCCESS_IO_PENDING) { - Debug.Assert(TdsEnums.SNI_SUCCESS != error, "Unexpected successful read async on physical connection before enabling MARS!"); + Debug.Assert(error != TdsEnums.SNI_SUCCESS, "Unexpected successful read async on physical connection before enabling MARS!"); _physicalStateObj.AddError(ProcessSNIError(_physicalStateObj)); ThrowExceptionAndWarning(_physicalStateObj); } @@ -982,19 +960,25 @@ private void EnableSsl(uint info, SqlConnectionEncryptOption encrypt, bool integ ThrowExceptionAndWarning(_physicalStateObj); } + SslProtocols protocol = 0; + // in the case where an async connection is made, encryption is used and Windows Authentication is used, // wait for SSL handshake to complete, so that the SSL context is fully negotiated before we try to use its // Channel Bindings as part of the Windows Authentication context build (SSL handshake must complete // before calling SNISecGenClientContext). - error = SniNativeWrapper.SniWaitForSslHandshakeToComplete(_physicalStateObj.Handle, _physicalStateObj.GetTimeoutRemaining(), out uint protocolVersion); - - if (error != TdsEnums.SNI_SUCCESS) +#if NET + if (OperatingSystem.IsWindows()) +#endif { - _physicalStateObj.AddError(ProcessSNIError(_physicalStateObj)); - ThrowExceptionAndWarning(_physicalStateObj); + error = _physicalStateObj.WaitForSSLHandShakeToComplete(out protocol); + if (error != TdsEnums.SNI_SUCCESS) + { + _physicalStateObj.AddError(ProcessSNIError(_physicalStateObj)); + ThrowExceptionAndWarning(_physicalStateObj); + } } - string warningMessage = ((System.Security.Authentication.SslProtocols)protocolVersion).GetProtocolWarning(); + string warningMessage = protocol.GetProtocolWarning(); if (!string.IsNullOrEmpty(warningMessage)) { if (!encrypt && LocalAppContextSwitches.SuppressInsecureTlsWarning) diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserStateObjectNative.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserStateObjectNative.cs index 807474d98b..a77ab597d1 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserStateObjectNative.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserStateObjectNative.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Runtime.CompilerServices; +using System.Security.Authentication; using System.Threading.Tasks; using Interop.Windows.Sni; using Microsoft.Data.Common; @@ -172,9 +173,54 @@ internal override uint DisableSsl() internal override uint EnableMars(ref uint info) => SniNativeWrapper.SniAddProvider(Handle, Provider.SMUX_PROV, ref info); + internal override uint PostReadAsyncForMars(TdsParserStateObject physicalStateObject) + { + // HACK HACK HACK - for Async only + // Have to post read to initialize MARS - will get callback on this when connection goes + // down or is closed. + + PacketHandle temp = default; + uint error = TdsEnums.SNI_SUCCESS; + +#if NETFRAMEWORK + RuntimeHelpers.PrepareConstrainedRegions(); +#endif + try + { } + finally + { + IncrementPendingCallbacks(); + SessionHandle handle = SessionHandle; + // we do not need to consider partial packets when making this read because we + // expect this read to pend. a partial packet should not exist at setup of the + // parser + Debug.Assert(physicalStateObject.PartialPacket == null); + temp = ReadAsync(handle, out error); + + Debug.Assert(temp.Type == PacketHandle.NativePointerType, "unexpected packet type when requiring NativePointer"); + + if (temp.NativePointer != IntPtr.Zero) + { + // Be sure to release packet, otherwise it will be leaked by native. + ReleasePacket(temp); + } + } + + Debug.Assert(IntPtr.Zero == temp.NativePointer, "unexpected syncReadPacket without corresponding SNIPacketRelease"); + return error; + } + internal override uint SetConnectionBufferSize(ref uint unsignedPacketSize) => SniNativeWrapper.SniSetInfo(Handle, QueryType.SNI_QUERY_CONN_BUFSIZE, ref unsignedPacketSize); + internal override uint WaitForSSLHandShakeToComplete(out SslProtocols protocolVersion) + { + uint returnValue = SniNativeWrapper.SniWaitForSslHandshakeToComplete(Handle, GetTimeoutRemaining(), out uint nativeProtocolVersion); + + protocolVersion = (SslProtocols)nativeProtocolVersion; + return returnValue; + } + internal override SniErrorDetails GetErrorDetails() { SniNativeWrapper.SniGetLastError(out SniError sniError); diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniHandle.netcore.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniHandle.netcore.cs index 1f3ee01ab8..bcd814270c 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniHandle.netcore.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniHandle.netcore.cs @@ -121,7 +121,7 @@ protected static void AuthenticateAsClient(SslStream sslStream, string serverNam /// /// Gets a value that indicates the security protocol used to authenticate this connection. /// - public virtual int ProtocolVersion { get; } = 0; + public virtual SslProtocols ProtocolVersion { get; } = 0; #if DEBUG /// diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniMarsConnection.netcore.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniMarsConnection.netcore.cs index 030dfb7452..3cef7f16df 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniMarsConnection.netcore.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniMarsConnection.netcore.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Security.Authentication; using System.Threading; namespace Microsoft.Data.SqlClient.ManagedSni @@ -32,7 +33,7 @@ internal class SniMarsConnection /// public Guid ConnectionId => _connectionId; - public int ProtocolVersion => _lowerHandle.ProtocolVersion; + public SslProtocols ProtocolVersion => _lowerHandle.ProtocolVersion; internal object DemuxerSync => _sync; diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniMarsHandle.netcore.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniMarsHandle.netcore.cs index ed69c242bf..11e9abf9bc 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniMarsHandle.netcore.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniMarsHandle.netcore.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Security.Authentication; using System.Threading; namespace Microsoft.Data.SqlClient.ManagedSni @@ -49,7 +50,7 @@ internal sealed class SniMarsHandle : SniHandle public override int ReserveHeaderSize => SniSmuxHeader.HEADER_LENGTH; - public override int ProtocolVersion => _connection.ProtocolVersion; + public override SslProtocols ProtocolVersion => _connection.ProtocolVersion; /// /// Dispose object diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniNpHandle.netcore.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniNpHandle.netcore.cs index 7a1c2ec660..f19dc4a33e 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniNpHandle.netcore.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniNpHandle.netcore.cs @@ -123,13 +123,13 @@ public SniNpHandle(string serverName, string pipeName, TimeoutTimer timeout, boo public override uint Status => _status; - public override int ProtocolVersion + public override SslProtocols ProtocolVersion { get { try { - return (int)_sslStream.SslProtocol; + return _sslStream.SslProtocol; } catch { diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniTcpHandle.netcore.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniTcpHandle.netcore.cs index 8960801967..ae04c7aa9f 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniTcpHandle.netcore.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniTcpHandle.netcore.cs @@ -98,13 +98,13 @@ public override uint Status } } - public override int ProtocolVersion + public override SslProtocols ProtocolVersion { get { try { - return (int)_sslStream.SslProtocol; + return _sslStream.SslProtocol; } catch { diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObject.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObject.cs index 2d1810abfb..479bdd0ae7 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObject.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObject.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Security; +using System.Security.Authentication; using System.Security.Cryptography; using System.Text; using System.Threading; @@ -533,12 +534,16 @@ internal long TimeoutTime internal abstract uint SniGetConnectionId(ref Guid clientConnectionId); + internal abstract uint WaitForSSLHandShakeToComplete(out SslProtocols protocolVersion); + internal abstract uint DisableSsl(); internal abstract SspiContextProvider CreateSspiContextProvider(); internal abstract uint EnableMars(ref uint info); + internal abstract uint PostReadAsyncForMars(TdsParserStateObject physicalStateObject); + internal abstract uint SetConnectionBufferSize(ref uint unsignedPacketSize); internal abstract void DisposePacketCache();