Windows 7中的错误:请求已中止:无法创建SSL/TLS安全通道



我有以下问题:
如果我用web浏览器打开地址https://info.protectiacivila.ro/test.php则文本";你好"显示

我在windows窗体应用程序(目标:.NET 4.5(中编写了以下点击事件处理程序:

private void button1_Click(object sender, EventArgs e) {
Uri uri = new Uri("https://info.protectiacivila.ro/test.php");
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;
HttpWebRequest request = WebRequest.Create(uri) as HttpWebRequest;
try {
string strResponse;
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) {
StreamReader reader = new StreamReader(response.GetResponseStream());
strResponse = reader.ReadToEnd();
}
MessageBox.Show(strResponse);
} catch (Exception ex) {
MessageBox.Show(ex.Message);
}
}

上述方法应该显示消息"0";你好">
它在Windows 10中运行良好。这意味着SSL证书是有效的

但是,在Windows 7中,它显示错误消息:
请求已中止:无法创建SSL/TLS安全通道

我能做些什么来使上述方法在Windows7中也能工作?

谢谢

Windows 7 SP1似乎支持TLS 1.1和1.2,但默认情况下未启用。例如,当您想在Windows 7上使用GIT时,也会出现此错误。解决方案是通过注册表启用它:

  1. 您需要创建一个注册表项:
HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSecurityProvidersSCHANNELProtocolsTLS 1.2Client
  1. 添加值为DisabledByDefault的DWORD 32位

来源:https://manage.accuwebhosting.com/knowledgebase/3008/How-do-I-enable-TLS-1-2-on-Windows-7.html

最新更新