默认情况下,Windows Embedded PosReady 2009 上未启用对 TLS1.2 的支持。
然而微软发布了 KB4019276 ( https://support.microsoft.com/en-us/help/4019276/update-to-add-support-for-tls-1-1-and-tls-1-2-in-windows ) 增加了这种支持。
我已将注册表 DWORD DisabledByDefault 添加到文章中定义的以下键中。
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server
我在安装 KB 并更改注册表后重新启动了设备,但它仍然对我不起作用。下面是我用来测试更改的 TLS1.2 代码。
例外是
System.NotSupportedException: The requested security protocol is not supported.
at System.Net.ServicePointManager.set_SecurityProtocol(SecurityProtocolType value)
代码使用 .net 3.5 编译,3.5 是该设备将支持的最高 .net 框架。
Console.WriteLine("Press Enter to send TLS1.2 to google.com");
Console.ReadLine();
System.Net.ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; // Sets TLS1.2. This will only work if the OS supports it.
string url = "https://www.google.com";
var req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "GET";
var resp = req.GetResponse();
var outStream = resp.GetResponseStream();
string output = "";
using (StreamReader rdr = new StreamReader(outStream))
{
output = rdr.ReadToEnd();
}
Console.WriteLine(output);
Console.ReadLine();