Guest User

Untitled

a guest
Jan 17th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. // callback used to validate the certificate in an SSL conversation
  2. private static bool ValidateRemoteCertificate(
  3. object sender,
  4. X509Certificate certificate,
  5. X509Chain chain,
  6. SslPolicyErrors policyErrors
  7. ) {
  8. // allow any old dodgy certificate...
  9. log.write(0, "entering ValidateRemoeCertificate ");
  10. return true;
  11. }
  12.  
  13. // getRequest
  14. private int getRequest()
  15. {
  16. try {
  17. log.write(1, "Validating " + webHostName);
  18. // request.Method = method;
  19. ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(ValidateRemoteCertificate);
  20. response = (HttpWebResponse)request.GetResponse();
  21. response.Close();
  22. } catch (Exception w) {
  23. if (w.Message.Contains("401"))
  24. {
  25. log.write(4, "Web Site Authentication Required for " + host + ":" + port);
  26. return 401;
  27. }
  28. else if (w.Message.Contains("403"))
  29. {
  30. log.write(4, "Forbidden Access for " + host + ":" + port);
  31. return 403;
  32. }
  33. else
  34. {
  35. log.write(4, "Error Reading Web Site " + host + " Port " + port + " " + w.Message);
  36. return 400;
  37. }
  38. }
  39. return 0;
  40. }
Add Comment
Please, Sign In to add comment