TrustAllCertificatePolicy

O

Oscar Thornell

Hi,

I am having some problems with missing intermediate root certificates in a
production env.
"The underlying connection was closed: Could not establish trust
relationship with remote server."

As I have understood it one way of solving this issue is to use the
"ServerCertificateValidationCallback" and implement the "ICertificatePolicy"
in a class and make the check return "True".

My question is this...

I have a factory that returns my client proxy...
MyService proxy = ServiceFactory.GetMyService();

//Calling Synchronous operations on the proxy
string id = proxy.SomeMethod();

//Calling Asynchronous operations on the proxy
proxy.BeginAnotherMethod(id, dataObj);
....

Is it sufficent to add the following code before the Factory call i.e.
before any operations have been invoked on the proxy or..??
Before calling the "new" operator on the proxy??
Before every operation called on the proxy??

//Using the callback
ServicePointManager.ServerCertificateValidationCallback =
TrustAllCertificatePolicy.TrustAllCertificateCallback;


// The override...
public class TrustAllCertificatePolicy : System.Net.ICertificatePolicy
{
public static bool TrustAllCertificateCallback(object sender,
X509Certificate cert, X509Chain chain, SslPolicyErrors errors)
{
return true;
}

public bool CheckValidationResult(System.Net.ServicePoint srvPoint,
X509Certificate certificate, System.Net.WebRequest request, int
certificateProblem)
{
return true;
}
}


Regards
/Oscar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top