小编Vio*_*rel的帖子

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

我遇到以下问题:
如果我使用网络浏览器打开地址https://info.protectiacivila.ro/test.php ,则显示文本“Hello!” 被展示。

我在 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);
  }
}
Run Code Online (Sandbox Code Playgroud)

上面的方法应该显示消息“Hello!”
它在Windows 10中完美运行。这意味着SSL证书是有效的。

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

我该怎么做才能使上述方法在 Windows 7 中也起作用?

谢谢

c# httpwebrequest ssl-certificate windows-7 winforms

0
推荐指数
1
解决办法
3393
查看次数