我们的应用程序使用Webbrowser控件/ Internet Explorer来显示一些网页。我们需要启用TLS 1.2(Internet选项->高级->安全->使用TLS 1.2)来显示这些网页。现在我们在Win 8中遇到了一些禁用(默认禁用) TLS 1.2选项的问题。因此,我们需要检查它是否被勾选,如果没有,我们需要在C#中以编程方式勾选它。我们已经尝试了设置注册表值,但没有任何帮助。有没有办法以编程方式勾选"Internet选项->高级->安全->使用TLS 1.2“。
发布于 2019-05-23 21:20:26
您可以使用Registry.SetValue Method来设置、更改注册表并启用TLS1.2。
代码如下(需要添加“使用Microsoft.Win32;”引用):
static void Main(string[] args)
{
// The name of the key must include a valid root.
const string userRoot = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings";
const string subkey = "SecureProtocols";
//get the registry value.
string result = (Registry.GetValue(userRoot, subkey, "Return this default if NoSuchName does not exist")).ToString();
Console.WriteLine(result);
//Enable TLS 1.0 and TLS 1.2
Registry.SetValue(userRoot, subkey, 2176);
Console.WriteLine("OK");
Console.ReadKey();
}有关注册表项值的更多详细信息,请参阅this article。
https://stackoverflow.com/questions/56269373
复制相似问题