surya narayana dash
surya narayana dash

Reputation: 67

make https request to wcf service: The remote certificate is invalid according to the validation procedure

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?

Upvotes: 5

Views: 5575

Answers (1)

Rasmita Dash
Rasmita Dash

Reputation: 937

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

Upvotes: 7

Related Questions