public class CertificateTrust
{
public static void SetCertificatePolicy()
{
//当在浏览器中可以正常访问,而code中出现错误时,可以用fiddle看下正常访问的SSl加密认证的版本号
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
ServicePointManager.ServerCertificateValidationCallback =
new System.Net.Security.RemoteCertificateValidationCallback(CheckValidationResult);
}
public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
return true;
}
}
连接client之前调用
CertificateTrust.SetCertificatePolicy();