0

Our application using Webbrowser control / Internet Explorer to display some web pages. We need to enable TLS 1.2(Internet Options->Advanced->Security->Use TLS 1.2) to display these web pages. Now we are facing some issues in Win 8 when disabling (by default disabled) TLS 1.2 option. So we need to check whether it is ticked and if not we need to tick it programmatically in 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.

Yamuna
  • 11
  • 5
  • Possible duplicate of [Update .NET web service to use TLS 1.2](https://stackoverflow.com/questions/45382254/update-net-web-service-to-use-tls-1-2) – Tayyab May 23 '19 at 06:54

1 Answers1

1

You could use the Registry.SetValue Method to set change the registry and enable TLS 1.2.

Code as below (need to add the "using Microsoft.Win32;" reference):

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.

Zhi Lv
  • 18,845
  • 1
  • 19
  • 30