Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/326.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.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# HttpWebRequest请求被中止:无法创建SSL/TLS安全通道_C#_Asp.net_Web Services_Ssl Certificate - Fatal编程技术网

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

C# HttpWebRequest请求被中止:无法创建SSL/TLS安全通道,c#,asp.net,web-services,ssl-certificate,C#,Asp.net,Web Services,Ssl Certificate,我开发了asp.net web应用程序,并在本地使用iisexpress运行它。 我想调用需要双向SSL的webservice 我有客户端证书,安装在我的本地机器上,完全控制网络服务,使用证书mmc记录用户 使用以下代码调用服务 ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityP

我开发了asp.net web应用程序,并在本地使用iisexpress运行它。 我想调用需要双向SSL的webservice

我有客户端证书,安装在我的本地机器上,完全控制网络服务,使用证书mmc记录用户

使用以下代码调用服务

 ServicePointManager.Expect100Continue = true;
        ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
     | SecurityProtocolType.Tls11
     | SecurityProtocolType.Tls12
     | SecurityProtocolType.Ssl3;

        HttpWebRequest request = WebRequest.Create(new Uri(_endPoint)) as HttpWebRequest;

        // Set type to POST
        request.Method = "GET";
        request.ContentType = "application/xml";
        _endPoint = _endPoint + "?callerFID='" + _callerFID + "'&callerID='" + _callerID;
        X509Certificate2 cert = new X509Certificate2("C:\\test.p12", "TEST");
        System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate(Object obj, X509Certificate X509certificate, X509Chain chain, System.Net.Security.SslPolicyErrors errors)
        {
            return true;
        };
        request.ClientCertificates.Add(cert);

        request.PreAuthenticate = true;
        try
        {
            using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
            {
                StreamReader reader = new StreamReader(response.GetResponseStream());
                string result = reader.ReadToEnd();
                reader.Close();
            }
            return new IMSUserManagementService.UserManagerV2Client(_endPoint);
        }
        catch (Exception)
        {

            throw;
        }
但出现异常:请求被中止:无法创建SSL/TLS安全通道


请帮助我解决此问题

若要了解导致错误的具体原因的更多信息,您应该使用Wireshark并查看客户端和服务器之间交换的SSL/TLS消息-这有助于我在没有“googleable”时解决SSL问题解决方案有所帮助。如果您的客户端证书是自签名的,请确保将它们也添加到受信任的证书存储中。还可以尝试使用Fiddler查看原始请求和响应,以便更好地了解您是否拥有您试图使用的web服务?谁是您拥有的客户端证书的颁发者?web服务信任这样的颁发者吗?我不拥有web服务,但web服务的所有者提供了客户端证书,web服务信任这样的颁发者