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

Support SuperSocketNetLib registry option for Encrypt on NetCore Windows #2047

Merged
merged 1 commit into from Jul 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -426,18 +426,6 @@ internal SqlConnectionString(string connectionString) : base(connectionString, G
}
}

if (_encrypt == SqlConnectionEncryptOption.Optional)
{ // Support legacy registry encryption settings
const string folder = "Software\\Microsoft\\MSSQLServer\\Client\\SuperSocketNetLib";
const string value = "Encrypt";

object obj = ADP.LocalMachineRegistryValue(folder, value);
if ((obj is int iObj) && (iObj == 1))
{ // If the registry key exists
_encrypt = SqlConnectionEncryptOption.Mandatory;
}
}

if (null != _networkLibrary)
{ // MDAC 83525
string networkLibrary = _networkLibrary.Trim().ToLower(CultureInfo.InvariantCulture);
Expand All @@ -454,6 +442,18 @@ internal SqlConnectionString(string connectionString) : base(connectionString, G
}
#endif // NETFRAMEWORK

if (_encrypt == SqlConnectionEncryptOption.Optional)
{ // Support legacy registry encryption settings
const string folder = "Software\\Microsoft\\MSSQLServer\\Client\\SuperSocketNetLib";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if this is still a valid path or not!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a less-known, legacy registry path. I don't even see it in current MS docs, but it was in the netfx code (and works in netfx SDS) and support has mentioned it from some customers.

const string value = "Encrypt";

object obj = ADP.LocalMachineRegistryValue(folder, value);
if ((obj is int iObj) && (iObj == 1))
{ // If the registry key exists
_encrypt = SqlConnectionEncryptOption.Mandatory;
}
}

ValidateValueLength(_applicationName, TdsEnums.MAXLEN_APPNAME, KEY.Application_Name);
ValidateValueLength(_currentLanguage, TdsEnums.MAXLEN_LANGUAGE, KEY.Current_Language);
ValidateValueLength(_dataSource, TdsEnums.MAXLEN_SERVERNAME, KEY.Data_Source);
Expand Down