Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix | Exclude unsupported protocols #1168

Merged
merged 8 commits into from
Aug 23, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Security.Authentication;

namespace Microsoft.Data.SqlClient.SNI
{
Expand All @@ -11,6 +12,11 @@ namespace Microsoft.Data.SqlClient.SNI
/// </summary>
internal abstract class SNIHandle
{
/// <summary>
/// TLS 1.3 (not fully supported) in addition to obsolete and insecure protocols are excluded.
/// </summary>
protected readonly SslProtocols SupportedProtocols = SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls;

/// <summary>
/// Dispose class
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,7 @@ public override uint EnableSsl(uint options)
_validateCert = (options & TdsEnums.SNI_SSL_VALIDATE_CERTIFICATE) != 0;
try
{

_sslStream.AuthenticateAsClient(_targetServer);
_sslStream.AuthenticateAsClient(_targetServer, null, SupportedProtocols, true);
_sslOverTdsStream.FinishHandshake();
}
catch (AuthenticationException aue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ public override uint EnableSsl(uint options)

try
{
_sslStream.AuthenticateAsClient(_targetServer);
_sslStream.AuthenticateAsClient(_targetServer, null, SupportedProtocols, true);
_sslOverTdsStream.FinishHandshake();
}
catch (AuthenticationException aue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,13 +421,9 @@ internal override uint WaitForSSLHandShakeToComplete(out int protocolVersion)
protocolVersion = (int)SslProtocols.Ssl2;
#pragma warning restore CS0618 // Type or member is obsolete : SSL is depricated
}
else if (nativeProtocol.HasFlag(NativeProtocols.SP_PROT_NONE))
{
protocolVersion = (int)SslProtocols.None;
}
else
{
throw new ArgumentException(StringsHelper.Format(StringsHelper.net_invalid_enum, nameof(NativeProtocols)), nameof(NativeProtocols));
throw ADP.Argument(StringsHelper.Format(StringsHelper.net_invalid_enum, nameof(NativeProtocols)), nameof(NativeProtocols));
}
return returnValue;
}
Expand Down