腾格里

程序员交流学习的网站
站长QQ:540329378

centos环境asp.net core出现The SSL connection could not be established异常

在centos环境asp.net core出现The SSL connection could not be established异常。
如下:
TIM图片20191111155051.png

用4种解决方式:

1 修改代码解决

  var httpClientHandler = new HttpClientHandler
    {
        ServerCertificateCustomValidationCallback = (message, certificate2, arg3, arg4) => true
    };
   HttpClient client = new HttpClient(httpClientHandler)

2 修改centos中asp.net core项目守护进程的配置文件
1111222.JPG

在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
  }
}
未经允许不得转载:腾格里 » centos环境asp.net core出现The SSL connection could not be established异常

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址