Update Microsoft.Data.SqlClient to v5.0.1 (#1708)

This commit is contained in:
Cheena Malhotra
2022-10-24 20:10:04 -07:00
committed by GitHub
parent 3be806ddce
commit c0f8482e26
30 changed files with 416 additions and 313 deletions

View File

@@ -91,14 +91,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
GroupName = "Initialization"
},
new ConnectionOption
{
Name = "asynchronousProcessing",
DisplayName = "Asynchronous processing enabled",
Description = "When true, enables usage of the Asynchronous functionality in the .Net Framework Data Provider",
ValueType = ConnectionOption.ValueTypeBoolean,
GroupName = "Initialization"
},
new ConnectionOption
{
Name = "connectTimeout",
DisplayName = "Connect timeout",
@@ -152,10 +144,14 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
{
Name = "encrypt",
DisplayName = "Encrypt",
Description =
"When true, SQL Server uses SSL encryption for all data sent between the client and server if the servers has a certificate installed",
Description = "When set, SQL Server uses provided setting for SSL encryption for all data sent between the client and server.",
ValueType = ConnectionOption.ValueTypeCategory,
GroupName = "Security",
ValueType = ConnectionOption.ValueTypeBoolean
CategoryValues = new CategoryValue[] {
new CategoryValue { DisplayName = "Optional", Name = "Optional" },
new CategoryValue { DisplayName = "Mandatory", Name = "Mandatory" },
new CategoryValue { DisplayName = "Strict", Name = "Strict" }
}
},
new ConnectionOption
{
@@ -174,6 +170,14 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
ValueType = ConnectionOption.ValueTypeBoolean
},
new ConnectionOption
{
Name = "hostNameInCertificate",
DisplayName = "HostNameInCertificate",
Description = "Specifies host name in certificate to be used for certificate validation, when encryption is enabled.",
GroupName = "Security",
ValueType = ConnectionOption.ValueTypeString,
},
new ConnectionOption
{
Name = "attachedDBFileName",
DisplayName = "Attached DB file name",

View File

@@ -410,7 +410,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
if (response?.ErrorNumber == 40613)
{
counter++;
if(counter != MaxServerlessReconnectTries) {
if (counter != MaxServerlessReconnectTries)
{
Logger.Information($"Database for connection {connectionInfo.OwnerUri} is paused, retrying connection. Attempt #{counter}");
}
}
@@ -1299,14 +1300,26 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
connectionBuilder.EnclaveAttestationUrl = connectionDetails.EnclaveAttestationUrl;
}
if (connectionDetails.Encrypt.HasValue)
if (!string.IsNullOrEmpty(connectionDetails.Encrypt))
{
connectionBuilder.Encrypt = connectionDetails.Encrypt.Value;
connectionBuilder.Encrypt = connectionDetails.Encrypt.ToLowerInvariant() switch
{
"optional" or "false" or "no" => SqlConnectionEncryptOption.Optional,
"mandatory" or "true" or "yes" => SqlConnectionEncryptOption.Mandatory,
"strict" => SqlConnectionEncryptOption.Strict,
_ => throw new ArgumentException(SR.ConnectionServiceConnStringInvalidEncryptOption(connectionDetails.Encrypt))
};
}
if (connectionDetails.TrustServerCertificate.HasValue)
{
connectionBuilder.TrustServerCertificate = connectionDetails.TrustServerCertificate.Value;
}
if (!string.IsNullOrEmpty(connectionDetails.HostNameInCertificate))
{
connectionBuilder.HostNameInCertificate = connectionDetails.HostNameInCertificate;
}
if (connectionDetails.PersistSecurityInfo.HasValue)
{
connectionBuilder.PersistSecurityInfo = connectionDetails.PersistSecurityInfo.Value;
@@ -1471,8 +1484,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
ColumnEncryptionSetting = builder.ColumnEncryptionSetting.ToString(),
EnclaveAttestationProtocol = builder.AttestationProtocol == SqlConnectionAttestationProtocol.NotSpecified ? null : builder.AttestationProtocol.ToString(),
EnclaveAttestationUrl = builder.EnclaveAttestationUrl,
Encrypt = builder.Encrypt,
Encrypt = builder.Encrypt.ToString(),
FailoverPartner = builder.FailoverPartner,
HostNameInCertificate = builder.HostNameInCertificate,
LoadBalanceTimeout = builder.LoadBalanceTimeout,
MaxPoolSize = builder.MaxPoolSize,
MinPoolSize = builder.MinPoolSize,

View File

@@ -147,13 +147,13 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
}
/// <summary>
/// Gets or sets a Boolean value that indicates whether SQL Server uses SSL encryption for all data sent between the client and server if the server has a certificate installed.
/// Gets or sets a <see cref="string"/> value that indicates encryption mode that SQL Server should use to perform SSL encryption for all the data sent between the client and server. Supported values are: Optional, Mandatory, Strict.
/// </summary>
public bool? Encrypt
public string Encrypt
{
get
{
return GetOptionValue<bool?>("encrypt");
return GetOptionValue<string>("encrypt");
}
set
@@ -178,6 +178,22 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
}
}
/// <summary>
/// Gets or sets a value that indicates the host name in the certificate to be used for certificate validation when encryption is enabled.
/// </summary>
public string HostNameInCertificate
{
get
{
return GetOptionValue<string>("hostNameInCertificate");
}
set
{
SetOptionValue("hostNameInCertificate", value);
}
}
/// <summary>
/// Gets or sets a Boolean value that indicates if security-sensitive information, such as the password, is not returned as part of the connection if the connection is open or has ever been in an open state.
/// </summary>

View File

@@ -27,6 +27,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
EnclaveAttestationUrl = details.EnclaveAttestationUrl,
Encrypt = details.Encrypt,
TrustServerCertificate = details.TrustServerCertificate,
HostNameInCertificate = details.HostNameInCertificate,
PersistSecurityInfo = details.PersistSecurityInfo,
ConnectTimeout = details.ConnectTimeout,
ConnectRetryCount = details.ConnectRetryCount,