NetCore HttpClient The SSL connection could not be established, see inner exception

之前遇到一个问题

 

https://www.cnblogs.com/leoxjy/p/10201046.html

 

在centos 7.x  HttpClient访问会出问题  The SSL connection could not be established, see inner exception

最后彻底解决是进入容器docker

那么 最近又FQ搜到一个解决方案 可以systemctl 运行的时候也不会 SSL

上代码

       var httpClientHandler = new HttpClientHandler
            {
                ServerCertificateCustomValidationCallback = (message, certificate2, arg3, arg4) => true
            };
            using (HttpClient client = new HttpClient(httpClientHandler))
            {
                string url = WeiXinSettings.GetJscode2Session(code);

                var result = await client.GetAsync(url);

                if (result.IsSuccessStatusCode)
                {
                    string str = await result.Content.ReadAsStringAsync();

                    return str;
                }
            }

  

 

上一篇:5、Shell变量:Shell变量的定义、删除变量、只读变量、变量类型


下一篇:JVM Object