在请求下函数前面加一句这样的话,就可以实行对https协议的网站进行下载。
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{ // Always accept
Console.WriteLine("accept" + certificate.GetName());
return true; //总是接受
}
public class AcceptAllCertificatePolicy : ICertificatePolicy
{
public AcceptAllCertificatePolicy()
{
//
// TODO: Add constructor logic here
//
}
public bool CheckValidationResult(ServicePoint sPoint,
X509Certificate cert, WebRequest wRequest, int certProb)
{
// Always accept
return true;
}
}
{
public AcceptAllCertificatePolicy()
{
//
// TODO: Add constructor logic here
//
}
public bool CheckValidationResult(ServicePoint sPoint,
X509Certificate cert, WebRequest wRequest, int certProb)
{
// Always accept
return true;
}
}