runliuv

runliuv@cnblogs

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

 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。

posted on 2022-12-14 17:05  runliuv  阅读(568)  评论(0编辑  收藏  举报