Skip to content

Instantly share code, notes, and snippets.

@jinweijie
Created February 21, 2013 06:50
Show Gist options
  • Select an option

  • Save jinweijie/5002787 to your computer and use it in GitHub Desktop.

Select an option

Save jinweijie/5002787 to your computer and use it in GitHub Desktop.
Skip certificate check
static void Main(string[] args)
{
ServicePointManager.ServerCertificateValidationCallback +=
new RemoteCertificateValidationCallback(ValidateCertificate);
Console.WriteLine("Client starting...");
ApplicationService svc = new ApplicationService();
App app = svc.GetAppInfo();
Console.WriteLine(string.Format("AppName:{0}", app.Name));
Console.WriteLine(string.Format("Module Count:{0}", app.Modules.Count()));
Console.Read();
}
public static bool ValidateCertificate(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
return true;
if(sslPolicyErrors == SslPolicyErrors.RemoteCertificateChainErrors)
{
foreach(X509ChainStatus chainStatus in chain.ChainStatus)
{
if(chainStatus.Status == X509ChainStatusFlags.Revoked)
{
return true;
}
}
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment