5

I have a service hosted over http/https on my local machine. When I consume the service over http it works perfectly. It also works when I make https request on ajax. But it's not work, when I try to consume it from code behind of client app. It shows the an error message as follows:

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

Can somebody help me out?

stanleyxu2005
  • 8,081
  • 14
  • 59
  • 94
  • possible duplicate : http://stackoverflow.com/questions/777607/the-remote-certificate-is-invalid-according-to-the-validation-procedure-using – 2GDev Aug 25 '14 at 12:05

1 Answers1

7

This is because, the certificate you use on your local IIS, is a virtual one. Probably, you will not get it in real time. There are several hacks available to make it work locally.

NOTE: Never ever do this on production...

Add following code segment(an event handler), before calling any method of service.

 ServicePointManager.ServerCertificateValidationCallback +=
        EasyCertCheck;

 bool EasyCertCheck(object sender, X509Certificate cert,
   X509Chain chain, System.Net.Security.SslPolicyErrors error)
    {
        return true;
    }
Rasmita Dash
  • 917
  • 5
  • 15
  • 28