【问题标题】:How to tick "TLS 1.2"(Internet Option > Advanced setting > Security> TLS 1.2) using C#如何使用 C# 勾选“TLS 1.2”(Internet 选项> 高级设置> 安全> TLS 1.2)
【发布时间】:2019-10-09 16:23:30
【问题描述】:

我们的应用程序使用 Webbrowser 控件/Internet Explorer 来显示一些网页。我们需要启用 TLS 1.2(Internet 选项->高级->安全->使用 TLS 1.2)来显示这些网页。现在,当禁用(默认禁用)TLS 1.2 选项时,我们在 Win 8 中遇到了一些问题。所以我们需要检查它是否被勾选,如果没有,我们需要在 C# 中以编程方式勾选它。我们尝试过设置注册表值,但没有帮助。 有没有办法以编程方式勾选“Internet选项->高级->安全->使用TLS 1.2”。

【问题讨论】:

标签: c# .net webbrowser-control internet-explorer-10 tls1.2


【解决方案1】:

您可以使用Registry.SetValue Method 设置更改注册表并启用 TLS 1.2。

代码如下(需添加“using 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。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-21
    • 2018-01-07
    • 1970-01-01
    • 2019-12-13
    • 1970-01-01
    • 2018-04-06
    相关资源
    最近更新 更多