TrustAllCertificatePolicy

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Oscar Thornell

    TrustAllCertificatePolicy

    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
    "ServerCertific ateValidationCa llback" and implement the "ICertificatePo licy"
    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.SomeMetho d();

    //Calling Asynchronous operations on the proxy
    proxy.BeginAnot herMethod(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
    ServicePointMan ager.ServerCert ificateValidati onCallback =
    TrustAllCertifi catePolicy.Trus tAllCertificate Callback;


    // The override...
    public class TrustAllCertifi catePolicy : System.Net.ICer tificatePolicy
    {
    public static bool TrustAllCertifi cateCallback(ob ject sender,
    X509Certificate cert, X509Chain chain, SslPolicyErrors errors)
    {
    return true;
    }

    public bool CheckValidation Result(System.N et.ServicePoint srvPoint,
    X509Certificate certificate, System.Net.WebR equest request, int
    certificateProb lem)
    {
    return true;
    }
    }


    Regards
    /Oscar


Working...