All pastes #2071657 Raw Edit

Certificate Validation Disable i

public text v1 · immutable
#2071657 ·published 2011-05-29 17:42 UTC
rendered paste body

// Code to fallover gracefully.
try
{
      ServicePointManager.ServerCertificateValidationCallback += customXertificateValidation;
}
catch (NotImplementedException)
{
      try
      {
#pragma warning disable 0612, 0618
       // Mono does not implement the ServicePointManager.ServerCertificateValidationCallback yet!  Don't remove this!
            ServicePointManager.CertificatePolicy = new MonoCert();
#pragma warning restore 0612, 0618
       }
       catch (Exception)
       {
            m_log.Error("[OGP]: Certificate validation handler change not supported.  You may get ssl certificate validation errors teleporting from your region to some SSL regions.");
       }
}

// Newer SSL Cert Checking Disabler
private static bool customXertificateValidation(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors error)
{
     return true;   
}


// Older SSL Cert Checking Disabler
public class MonoCert : ICertificatePolicy
{
        #region ICertificatePolicy Members

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

        #endregion
}