繁体   English   中英

无法建立 SSL 连接。 认证失败

[英]The SSL connection could not be established. Authentication failed

我收到“无法建立 SSL 连接,请参阅内部异常。身份验证失败,请参阅内部异常”的错误消息。 当尝试通过 C# HttpWebRequest 通过 SSL POST 请求时(尝试过 RestSharp 和 HttpClient 结果是一样的)。 我还尝试了网络上提到的所有可能的解决方案,例如:

ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, errors) =>
            { return true; };
ServicePointManager.DefaultConnectionLimit = 9999;
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;

他们都没有为我工作。 另一个问题是我在另一台计算机上运行相同的项目,它没有任何问题。 所以看起来问题根源是环境,可能是.net框架或regedit中的一些设置应该改变。 谁能帮我这个?

该问题可能与 TLS 版本有关(请参阅此处有关安全协议类型的更多信息)。 一个想法是尝试使用更多的安全协议类型,如果它正常工作,您可以检查可以使用哪种协议:

ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, errors) =>
            { return true; };
ServicePointManager.DefaultConnectionLimit = 9999;
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls13;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM