在centos环境asp.net core出现The SSL connection could not be established异常。
如下:
用4种解决方式:
1 修改代码解决
var httpClientHandler = new HttpClientHandler
{
ServerCertificateCustomValidationCallback = (message, certificate2, arg3, arg4) => true
};
HttpClient client = new HttpClient(httpClientHandler)
2 修改centos中asp.net core项目守护进程的配置文件
在environment节点下 设置
DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0
3 程序运行时增加DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0
如:
DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0 dotnet Web.dll
**4 修改project.runtimeconfig.json文件
"runtimeOptions": {
"configProperties": {
"System.Net.Http.UseSocketsHttpHandler": false
}
}