Make https request to wcf service: remote certificate is invalid according to validation procedure

I have a service hosted on top of http / https on my local machine. When I use the service over http it works fine. It also works when I make an https request on ajax. But it doesn't work when I try to use it from client application code. It shows an error message like this:

"The remote certificate is invalid according to the validation procedure"

      

Can anyone help me?

+3


source to share


1 answer


This is because the certificate you are using in local IIS is virtual. You probably won't get it in real time. Several hacks are available to make it work locally.

NOTE: Never do this in production ...



Add the following code segment (event handler) before calling any service method.

 ServicePointManager.ServerCertificateValidationCallback +=
        EasyCertCheck;

 bool EasyCertCheck(object sender, X509Certificate cert,
   X509Chain chain, System.Net.Security.SslPolicyErrors error)
    {
        return true;
    }

      

+5


source







All Articles