By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,894 Members | 2,185 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,894 IT Pros & Developers. It's quick & easy.

TrustAllCertificatePolicy

P: n/a
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.ServerCertificateValidationCal lback =
TrustAllCertificatePolicy.TrustAllCertificateCallb ack;
// 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
Oct 2 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.