其他分享
首页 > 其他分享> > 针对HTTPS 安全链接失败 解决办法

针对HTTPS 安全链接失败 解决办法

作者:互联网

解决因为https 安全请求导致的  安全连接失败问题

放在请求方法前面:

ServicePointManager.ServerCertificateValidationCallback = Callback;//需要配一个方法
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

 

     /// <summary>
        /// 针对https 域名
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="certificate"></param>
        /// <param name="chain"></param>
        /// <param name="sslPolicyErrors"></param>
        /// <returns></returns>
        private static bool Callback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
        {
            return true;
        }

 

标签:解决办法,HTTPS,安全,ServicePointManager,Callback,失败,https,链接,请求
来源: https://www.cnblogs.com/dyd520/p/13938367.html