0
votes

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

To get more information about what exactly is causing the error you should use Wireshark and view the SSL/TLS messages exchanged between your client and server - this helped me resolve my SSL issues when none of the "googleable" solutions helped.Ivan G
If your client certificates are self signed make sure to add them to the trusted certificate store as well. Also try using Fiddler to view the raw request and response to get a better understandingRajesh
Do you own the web service that you are trying to consume? Who is the issuer of the client certificate that you have? Does the web service trust such issuer?Yacoub Massad
i do not own the web service but owner of web service have provided client certificate and web service trust such issuerSagar Modi