[英]How to tick “TLS 1.2”(Internet Option > Advanced setting > Security> TLS 1.2) using C#
Our application using Webbrowser control / Internet Explorer to display some web pages. 我们的应用程序使用Webbrowser控件/ Internet Explorer来显示一些网页。 We need to enable TLS 1.2(Internet Options->Advanced->Security->Use TLS 1.2) to display these web pages.
我们需要启用TLS 1.2(Internet选项 - >高级 - >安全 - >使用TLS 1.2)来显示这些网页。 Now we are facing some issues in Win 8 when disabling (by default disabled) TLS 1.2 option.
现在,当禁用(默认禁用)TLS 1.2选项时,我们在Win 8中遇到了一些问题。 So we need to check whether it is ticked and if not we need to tick it programmatically in C#.
所以我们需要检查它是否被勾选,如果不是,我们需要在C#中以编程方式勾选它。 We have tried by setting registry value but it doesn't' help.
我们尝试过设置注册表值,但它没有帮助。 Is there any way to tick "Internet Options->Advanced->Security->Use TLS 1.2" programmatically.
有没有办法以编程方式勾选“Internet选项 - >高级 - >安全 - >使用TLS 1.2”。
You could use the Registry.SetValue Method to set change the registry and enable TLS 1.2. 您可以使用Registry.SetValue方法设置更改注册表并启用TLS 1.2。
Code as below (need to add the "using Microsoft.Win32;" reference): 代码如下(需要添加“使用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();
}
More details about the registry key value, please refer to this article . 有关注册表项值的更多详细信息,请参阅此文章 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.