简体   繁体   中英

“The remote certificate is invalid according to the validation procedure” wcf

There's a problem. I have a site, that expanded locally on IIS, that needs to be connected to the remote WCF service. I've added all required certificates to the TrustedRoot store of LocalComputer . I've granted all permissions to my domain account for using certificates. But there's still a problem:

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

when I'm trying to run method of WCF-service (but it's connected to this WCF service fine).

I have some thinks about that:

1) Maybe I need to select SSL on IIS setting of this site?

2) Maybe I need to put certificates not only to LocalMachine , but to the CurrentUser too?

Advice me some tips for how to establish SSL connection and pass this exception. Thank you :)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM