Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void Main(string[] args)
- {
- String url = "https://www.example.com";
- HttpWebRequest request = WebRequest.CreateHttp( url );
- request.ServerCertificateValidationCallback += ServerCertificateValidationCallback;
- using( HttpWebResponse response = (HttpWebResponse)request.GetResponse() ) { }
- Console.WriteLine("End");
- Console.ReadKey();
- }
- private static bool ServerCertificateValidationCallback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
- {
- if (sslPolicyErrors == SslPolicyErrors.None)
- {
- Console.WriteLine("Certificate OK");
- return true;
- }
- else
- {
- Console.WriteLine("Certificate ERROR");
- return false;
- }
- }
Add Comment
Please, Sign In to add comment