HttpWebRequest The request was aborted: Could not create SSL/TLS secure channel

岁酱吖の 提交于 2019-12-25 11:57:25

问题


I have deveoped asp.net web application and running it using iisexpress in local. I want to call webservice which require two wayssl.

I have client certificate, installed in my local machine, given full control to Network_service, loggedin user using certificate mmc.

Calling service using following code

 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;
        }

But Getting exception: The request was aborted: Could not create SSL/TLS secure channel

Please help me to solve the issue

来源:https://stackoverflow.com/questions/32628440/httpwebrequest-the-request-was-aborted-could-not-create-ssl-tls-secure-channel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!