#region private static bool ValidateServerCertificate 解决Error"基础连接已经关闭: 未能为SSL/TLS 安全通道建立信任关系。" /// <summary> /// 解决Error"基础连接已经关闭: 未能为SSL/TLS 安全通道建立信任关系。" /// </summary> /// <param name="sender"></param> /// <param name="certificate"></param> /// <param name="chain"></param> /// <param name="sslPolicyErrors"></param> /// <returns></returns> private static bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; } #endregion .............................. .............................. ............................. ServicePointManager.ServerCertificateValidationCallback = ValidateServerCertificate; byte[] responseArray = webClient.UploadValues(url, postValues);
在请求之前加上
ServicePointManager.ServerCertificateValidationCallback = ValidateServerCertificate;
时间: 2024-12-29 11:32:56