C# .NET HttpWebRequest 按每个(单个)请求跳过证书校验
自签名证书 HTTPS TLS 。
使用.NET 4.5 新加的属性 HttpWebRequest.ServerCertificateValidationCallback。
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.ServerCertificateValidationCallback = (_s, _x509s, _x509c, _ssl) => { return (true); };
-
.NET 4.5 之前只能用全局的配置:
ServicePointManager.ServerCertificateValidationCallback
System.Net.ServicePointManager.ServerCertificateValidationCallback += (s, cert, chain, sslPolicyErrors) => true;
ServicePointManager.SecurityProtocol。