Hello,
I'm trying to do a secure connect to the site https://212.77.100.18/p/ with
..net 2.0 HttpWebRequest class,
unfortunately for some reason I'm not able to do that - WebException is
thrown with inner exception message of "An existing connection was forcibly
closed by the remote host."
I hoped I'll solve my problem with RemoteCertificateValidationCallback
delegate which always returns "true", but it isn't called at all for this
site (but works for other sites which needs manual acceptance of
certificate).
The HttpWebResponse should return "403 Forbidden" as in Internet Explorer.
Can you help me, please?
//my code below
ServicePointManager.ServerCertificateValidationCal lback
+= new
System.Net.Security.RemoteCertificateValidationCal lback(ValidateServerCertificate);
HttpWebRequest req =
(HttpWebRequest)WebRequest.Create("https://212.77.100.18/p/");
req.Method = "GET";
req.AllowAutoRedirect = false;
req.CookieContainer = new CookieContainer();
req.KeepAlive = true;
req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0;
Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC
4.0; .NET CLR 2.0.50727)";
req.ContentType = "application/x-www-form-urlencoded";
req.Accept = "*/*";
/*
I have also tried this:
req.ClientCertificates.Add(X509Certificate.CreateF romCertFile("chris.cer"));
*/
using (HttpWebResponse res =
(HttpWebResponse)req.GetResponse())
{
//not reached
}
public static bool ValidateServerCertificate(object sender,
X509Certificate certificate, X509Chain chain, SslPolicyErrors
sslPolicyErrors)
{
return true;
}