【问题标题】:Error: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel错误:底层连接已关闭:无法为 SSL/TLS 安全通道建立信任关系
【发布时间】:2015-09-16 12:35:20
【问题描述】:

我有使用 Web 服务的工具。我为 Web 服务生成了一个自签名证书,使用证书管理器将其导出到本地路径。

我正在按照以下 msdn 代码通过 webservice 将证书添加到其中。 https://support.microsoft.com/en-us/kb/901183

string certPath = @"C:\TestData\certificate.cer";
test.ClientCertificates.Add(X509Certificate.CreateFromCertFile(certPath));

上面是我的代码。

我收到以下错误。

The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.

堆栈跟踪:

at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at web_Client.testClient.testClassWebService.Add(Request request) in  C:\Workspace\Reference.cs:line 248
at web_Client.WebClient.Add() in C:\Workspace\WebClient.cs:line 227

我不知道发生了什么。我对网络和证书很陌生。请帮忙。

【问题讨论】:

    标签: c# ssl system.net.webexception


    【解决方案1】:

    在过去的几天里,我在一个之前运行良好的应用程序中遇到了这个问题。我认为拥有服务器的人更新了一些东西,现在他们需要不同的协议。我只是通过迁移到更高的框架版本解决了其中一个问题。对于第二个,我不得不移动到更高版本(4.5)并将 ServicePointManager.SecurityProtocol 设置为不同的协议。您可以使用智能感知来查看您的选项。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-06-28
      • 1970-01-01
      • 2011-01-06
      • 2017-05-22
      • 1970-01-01
      相关资源
      最近更新 更多