跳至主要内容

C# 基础连接已经关闭: 未能为 SSL/TLS 安全通道建立信任关系 解决办法

private static bool RemoteCertificateValidate(object sender, X509Certificate cert,X509Chain chain, SslPolicyErrors error)
{
    // trust any certificate!!!
    System.Console.WriteLine("Warning, trust any certificate");
    //为了通过证书验证,总是返回true
    return true;
}

ServicePointManager.ServerCertificateValidationCallback += RemoteCertificateValidate;//验证服务器证书回调自动验证

评论

此博客中的热门博文