【问题标题】:Anyway to enable solution level SSL using dotnet CLI?无论如何要使用 dotnet CLI 启用解决方案级别的 SSL?
【发布时间】:2021-05-05 12:44:11
【问题描述】:

我正在使用dotnet CLI 通过 Powershell 脚本运行项目。当我们第一次加载解决方案时,会弹出一个 SSL 通知,提供是/否选项。我想接受或使用dotnet CLI 将 SSL 设置为 true。

这是未启用 SSL 时出现的错误,

System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.
---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.
at System.Net.Security.SslStream.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, ExceptionDispatchInfo exception)

【问题讨论】:

    标签: .net visual-studio powershell .net-core dotnet-cli


    【解决方案1】:

    在执行 HTTPS 请求之前。添加下面的代码行。它会解决问题

    System.Net.ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => true;
    

    【讨论】:

    • 感谢@Tech-leo,这可以使用 dotnet cli 完成吗?
    • 是的,您可以在 Program.cs 文件中添加它
    【解决方案2】:

    基本上,SSL 需要被信任。该项目也能够在没有任何 iisSettings 的情况下执行。

    此命令有助于信任 ssl 证书。

    dotnet dev-certs https --trust
    

    BlogGitHub issue 对我帮助很大。

    【讨论】:

      猜你喜欢
      • 2017-09-09
      • 2021-09-19
      • 2018-12-30
      • 2011-07-13
      • 2020-01-27
      • 1970-01-01
      • 2012-12-08
      • 1970-01-01
      • 2020-06-12
      相关资源
      最近更新 更多