ServicePointManager.ServerCertificateValidationCallback not being hit
Asked Answered
M

1

6

I have the following code.

public void Submit(string XML)
{
ServicePointManager.ServerCertificateValidationCallback = ValidateCertificate;
TestWS.CW serv = new TestWS.CW();
string s = serv.Check(XML);
}

private static bool ValidateCertificate(object sender, X509Certificate cert, X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
return true;
}

However the code never enters the ValidateCertificate method.... It does if I submit a standard HttpsWebRequest but if I use a webservice it does not work. What am I doing wrong?

Moreira answered 20/12, 2012 at 12:33 Comment(3)
Even If it does, your ValidateCertificate method return always true .Shelley
I know, it is supposed to always return true.Moreira
did you manage to solve this?Celestinecelestite
B
7

Stick this in your startup code for your HTTP processing somewhere...

ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

That does it for me, but I only do THIS for debug builds...

Bryanbryana answered 3/5, 2013 at 19:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.