Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 请求被中止:无法创建SSL/TLS安全通道.Net 4.5.2_C#_Model View Controller - Fatal编程技术网

C# 请求被中止:无法创建SSL/TLS安全通道.Net 4.5.2

C# 请求被中止:无法创建SSL/TLS安全通道.Net 4.5.2,c#,model-view-controller,C#,Model View Controller,请有人帮帮我, 当我调用第三方Web服务时,它显示: 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

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

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证书,请向用户everyone授予完全权限。

当web服务的SSL证书无效时,可能会出现这种情况

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

System.Net.ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback(delegate
{
    return true;
});
如果这解决了您的问题,那么您应该检查机器上的证书


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

1)检查事件日志。2) 您可以在浏览器中访问终结点吗?我无法访问终结点,因为无法从浏览器(https)访问Web服务。我该怎么办?如果端点根本不可访问,这不是编程问题。与供应商交谈:服务是否正常?你有正确的网址吗?请与网络管理员联系。防火墙会阻止它吗?服务已启动,但只能通过SOAPUI或Postman chrome连接。我怀疑这也是一个编程问题,但在我向我的供应商上报之前,我需要一个证明。我觉得澄清您的意思很重要:此代码不应在生产环境中使用@plusheen建议您使用它来测试是否存在证书问题,而不是作为修复。