HttpWebRequest 忽略证书

HttpWebRequest 忽略证书(.net 4.0):

 

System.Net.ServicePointManager.ServerCertificateValidationCallback =
new System.Net.Security.RemoteCertificateValidationCallback(CheckValidationResult);//验证服务器证书回调自动验证

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(new Uri(Url));

。。。

protected bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{ // 总是接受
return true;
}

 

posted on 2012-01-13 11:09  CosmoKey  阅读(1748)  评论(0编辑  收藏  举报

导航