Click here to Skip to main content
15,922,007 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I mocked web-service via SoapUI 4.6.2, that service is client side authenticated.

I tried to connect to the service by the following code:


C#
ServicePointManager.CertificatePolicy = new MyCertificateValidation();

            MyService.Url = "https://MyIP:9988/mockService?WSDL";
            NetworkCredential netCred = new NetworkCredential(
                "User", "password");
            ICredentials credentials = netCred.GetCredential(MyService.Url, "Basic");
            MyService.Credentials = credentials;
            MyService.PreAuthenticate = true;
            var resp = MyService.GetXmlObject();



And this is the definition for MyCertificateValidation() :


C#
class MyCertificateValidation : ICertificatePolicy
{
    private const uint CERT_E_UNTRUSTEDROOT = 0x800B0109;

    public MyCertificateValidation()
    {}

public bool CheckValidationResult(ServicePoint sp, X509Certificate cert, WebRequest req, int problem)
{
    bool returnValue = true;

    if((uint)problem == CERT_E_UNTRUSTEDROOT)
    {

            returnValue = true;
    }
    return returnValue;
}
}





Issue is i am getting the "Could not establish secure channel for SSL/TLS" exception while trying to sent request to the server.

And this is the stackTrace:


at System.Net.HttpWebRequest.finishGetResponse()
at System.Net.HttpWebRequest.GetResponse()
at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.SoapHttpClientProtocol.doInvoke(String methodName, Object[] parameters, WebClientAsyncResult asyncResult)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)



I am making the app for Windows mobile 6.5.
Posted
Updated 30-Jan-14 19:07pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900