簡體   English   中英

如何使用C#勾選“TLS 1.2”(Internet選項>高級設置>安全性> TLS 1.2)

[英]How to tick “TLS 1.2”(Internet Option > Advanced setting > Security> TLS 1.2) using C#

我們的應用程序使用Webbrowser控件/ Internet Explorer來顯示一些網頁。 我們需要啟用TLS 1.2(Internet選項 - >高級 - >安全 - >使用TLS 1.2)來顯示這些網頁。 現在,當禁用(默認禁用)TLS 1.2選項時,我們在Win 8中遇到了一些問題。 所以我們需要檢查它是否被勾選,如果不是,我們需要在C#中以編程方式勾選它。 我們嘗試過設置注冊表值,但它沒有幫助。 有沒有辦法以編程方式勾選“Internet選項 - >高級 - >安全 - >使用TLS 1.2”。

您可以使用Registry.SetValue方法設置更改注冊表並啟用TLS 1.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();
}

有關注冊表項值的更多詳細信息,請參閱此文章

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM