Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // callback used to validate the certificate in an SSL conversation
- private static bool ValidateRemoteCertificate(
- object sender,
- X509Certificate certificate,
- X509Chain chain,
- SslPolicyErrors policyErrors
- ) {
- // allow any old dodgy certificate...
- log.write(0, "entering ValidateRemoeCertificate ");
- return true;
- }
- // getRequest
- private int getRequest()
- {
- try {
- log.write(1, "Validating " + webHostName);
- // request.Method = method;
- ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(ValidateRemoteCertificate);
- response = (HttpWebResponse)request.GetResponse();
- response.Close();
- } catch (Exception w) {
- if (w.Message.Contains("401"))
- {
- log.write(4, "Web Site Authentication Required for " + host + ":" + port);
- return 401;
- }
- else if (w.Message.Contains("403"))
- {
- log.write(4, "Forbidden Access for " + host + ":" + port);
- return 403;
- }
- else
- {
- log.write(4, "Error Reading Web Site " + host + " Port " + port + " " + w.Message);
- return 400;
- }
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment