如何解决无论如何要使用 dotnet CLI 启用解决方案级别的 SSL?
我正在使用 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)
解决方法
在执行 HTTPS 请求之前。添加下面的代码行。它将解决问题
System.Net.ServicePointManager.ServerCertificateValidationCallback = (sender,certificate,chain,errors) => true;
,
基本上,需要信任 SSL。该项目也可以在没有任何 iisSettings 的情况下执行。
此命令有助于信任 ssl 证书。
dotnet dev-certs https --trust
这个Blog和GitHub issue对我帮助很大。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。