Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# remote web request certificate error

I am getting the following error when trying to perform a HttpWebRequest to a remote server over SSL (the url is https://sandbox.payfast.co.za):

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

The certificate seems to be valid and I can successfully make a web request to another url.

Could someone tell me how the .NET validates the certificate and how I can find out the exact problem with the certificate.

To try and bypass this I added:

        ServicePointManager.ServerCertificateValidationCallback 
        = (obj, certificate, chain, errors) => true;

But it seems this will not work in medium trust.

Any help appreciated.

Thanks Ben

like image 649
Ben Foster Avatar asked Mar 14 '10 19:03

Ben Foster


1 Answers

After testing testing a few requests to other url's we switched back to the one originally raising the certificate validation exception and it worked!

Both parties ensure me nothing was changed.

Either way, I found this post useful in trying to diagnose the problem further http://blogs.msdn.com/jpsanders/archive/2009/09/16/troubleshooting-asp-net-the-remote-certificate-is-invalid-according-to-the-validation-procedure.aspx

like image 160
Ben Foster Avatar answered Oct 10 '22 21:10

Ben Foster