Skip to content

Commit 3cb9730

Browse files
authored
Support SuperSocketNetLib registry option for Encrypt on NetCore Windows (#2047)
1 parent 1aa9af6 commit 3cb9730

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionString.cs

+12-12
Original file line numberDiff line numberDiff line change
@@ -426,18 +426,6 @@ internal SqlConnectionString(string connectionString) : base(connectionString, G
426426
}
427427
}
428428

429-
if (_encrypt == SqlConnectionEncryptOption.Optional)
430-
{ // Support legacy registry encryption settings
431-
const string folder = "Software\\Microsoft\\MSSQLServer\\Client\\SuperSocketNetLib";
432-
const string value = "Encrypt";
433-
434-
object obj = ADP.LocalMachineRegistryValue(folder, value);
435-
if ((obj is int iObj) && (iObj == 1))
436-
{ // If the registry key exists
437-
_encrypt = SqlConnectionEncryptOption.Mandatory;
438-
}
439-
}
440-
441429
if (null != _networkLibrary)
442430
{ // MDAC 83525
443431
string networkLibrary = _networkLibrary.Trim().ToLower(CultureInfo.InvariantCulture);
@@ -454,6 +442,18 @@ internal SqlConnectionString(string connectionString) : base(connectionString, G
454442
}
455443
#endif // NETFRAMEWORK
456444

445+
if (_encrypt == SqlConnectionEncryptOption.Optional)
446+
{ // Support legacy registry encryption settings
447+
const string folder = "Software\\Microsoft\\MSSQLServer\\Client\\SuperSocketNetLib";
448+
const string value = "Encrypt";
449+
450+
object obj = ADP.LocalMachineRegistryValue(folder, value);
451+
if ((obj is int iObj) && (iObj == 1))
452+
{ // If the registry key exists
453+
_encrypt = SqlConnectionEncryptOption.Mandatory;
454+
}
455+
}
456+
457457
ValidateValueLength(_applicationName, TdsEnums.MAXLEN_APPNAME, KEY.Application_Name);
458458
ValidateValueLength(_currentLanguage, TdsEnums.MAXLEN_LANGUAGE, KEY.Current_Language);
459459
ValidateValueLength(_dataSource, TdsEnums.MAXLEN_SERVERNAME, KEY.Data_Source);

0 commit comments

Comments
 (0)