繁体   English   中英

该请求已中止:无法创建SSL / TLS安全通道.Net 4.5.2

[英]The request was aborted: Could not create SSL/TLS secure channel .Net 4.5.2

当我调用第三方网络服务时,请有人帮助我,它显示:

Initializing
Generating WSDL
System.InvalidOperationException: General Error https://xxx ---> System.Net.WebException: There was an error downloading 'https:/xxx'. ---> System.Net.WebException: The request was aborted: Could not create 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.Discovery.DiscoveryClientProtocol.Download(String& url, String& contentType)
   --- End of inner exception stack trace ---
   at System.Web.Services.Discovery.DiscoveryClientProtocol.Download(String& url, String& contentType)
   at System.Web.Services.Discovery.DiscoveryClientProtocol.DiscoverAny(String url)
   at WebServiceStudio.Wsdl.ProcessRemoteUrls(DiscoveryClientProtocol client, StringCollection urls, XmlSchemas schemas, ServiceDescriptionCollection descriptions)
   --- End of inner exception stack trace ---
   at WebServiceStudio.Wsdl.ProcessRemoteUrls(DiscoveryClientProtocol client, StringCollection urls, XmlSchemas schemas, ServiceDescriptionCollection descriptions)
   at WebServiceStudio.Wsdl.Generate()

我已经尝试使用X509证书,给用户所有人完全许可。

当Web服务的SSL证书无效时,可能会发生这种情况。

要解决此问题,请尝试以下代码:

System.Net.ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback(delegate
{
    return true;
});

如果这解决了您的问题,则应检查计算机上的证书。

正如@ dman2306所说,这仅是为了检查证书是否是造成您问题的原因。 请勿在任何生产代码中使用此代码。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM