Created
February 21, 2013 06:50
-
-
Save jinweijie/5002787 to your computer and use it in GitHub Desktop.
Skip certificate check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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