黄聪

论SEO对人类的重要性,请看我的博客:hcsem.com

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
//解决方法:

//引入命名空间:
using System.Security.Cryptography.X509Certificates;
using System.Net.Security;


//定义方法:

private static bool RemoteCertificateValidate(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors error)
{
    //为了通过证书验证,总是返回true
    return true;
}


//调用方法一:

//在构造函数中调用:

static WxRequest()
{
    // 获取验证证书的回调函数
    ServicePointManager.ServerCertificateValidationCallback+=RemoteCertificateValidate;
}

//方法二:

//在WebRequest请求之前调用:

ServicePointManager.ServerCertificateValidationCallback+=RemoteCertificateValidate;

 

posted on 2019-04-23 11:18  黄聪  阅读(478)  评论(0编辑  收藏  举报