.net httpclient 请求报错:One or more errors occurred. (The SSL connection could not be established, see inner exception.) 电脑版发表于:2024/9/5 11:32 这是因为HttpClient请求的地址带https证书,如果遇到证书有问题,证书不合法什么的就请求不到了,我们可以这样设置一下解决这个问题。 ``` // 防止错误:One or more errors occurred. (The SSL connection could not be established, see inner exception.)” HttpClientHandler clientHandler = new HttpClientHandler(); clientHandler.ServerCertificateCustomValidationCallback += (sender, cert, chain, sslPolicyErrors) => { return true; }; clientHandler.SslProtocols = SslProtocols.None; HttpClient client = new HttpClient(clientHandler); ``` 一般这种错误都是测试环境出现的,正式环境请求一般都内部地址,速度也会快很多。