Guest User

Untitled

a guest
Apr 27th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. static void Main(string[] args)
  2. {
  3. String url = "https://www.example.com";
  4. HttpWebRequest request = WebRequest.CreateHttp( url );
  5. request.ServerCertificateValidationCallback += ServerCertificateValidationCallback;
  6. using( HttpWebResponse response = (HttpWebResponse)request.GetResponse() ) { }
  7. Console.WriteLine("End");
  8. Console.ReadKey();
  9. }
  10.  
  11. private static bool ServerCertificateValidationCallback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
  12. {
  13. if (sslPolicyErrors == SslPolicyErrors.None)
  14. {
  15. Console.WriteLine("Certificate OK");
  16. return true;
  17. }
  18. else
  19. {
  20. Console.WriteLine("Certificate ERROR");
  21. return false;
  22. }
  23. }
Add Comment
Please, Sign In to add comment