ubuntu - 如何在针对 UBUNTU 运行的 ASP.NET Core 2.1 应用程序中设置 HTTPS 证书?

标签 ubuntu https certificate asp.net-core-2.1

我有一个使用 ASP.NET Core 2.1 创建的简单 Web 应用程序,并且在调试时不断遇到 HTTPS 证书。

虽然它在 Windows 中运行良好,但由于缺少集中式证书存储,它在 Ubuntu 中无法运行。

Hosting environment: Development
Content root path: /home/perret/Desktop/Tests/Showtime/ConsoleAppPlaygroun/WebApplicationTest
Now listening on: https://localhost:5001
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.
dbug: HttpsConnectionAdapter[1]
      Failed to authenticate HTTPS connection.
System.IO.IOException: Authentication failed because the remote party has closed the transport stream.
   at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
   at System.Net.Security.SslStream.BeginAuthenticateAsServer(SslServerAuthenticationOptions sslServerAuthenticationOptions, CancellationToken cancellationToken, AsyncCallback asyncCallback, Object asyncState)
   at System.Net.Security.SslStream.<>c.<AuthenticateAsServerAsync>b__51_0(SslServerAuthenticationOptions arg1, CancellationToken arg2, AsyncCallback callback, Object state)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncImpl[TArg1,TArg2](Func`5 beginMethod, Func`2 endFunction, Action`1 endAction, TArg1 arg1, TArg2 arg2, Object state, TaskCreationOptions creationOptions)
   at System.Threading.Tasks.TaskFactory.FromAsync[TArg1,TArg2](Func`5 beginMethod, Action`1 endMethod, TArg1 arg1, TArg2 arg2, Object state, TaskCreationOptions creationOptions)
   at System.Threading.Tasks.TaskFactory.FromAsync[TArg1,TArg2](Func`5 beginMethod, Action`1 endMethod, TArg1 arg1, TArg2 arg2, Object state)
   at System.Net.Security.SslStream.AuthenticateAsServerAsync(SslServerAuthenticationOptions sslServerAuthenticationOptions, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Server.Kestrel.Https.Internal.HttpsConnectionAdapter.InnerOnConnectionAsync(ConnectionAdapterContext context)

我读:
  • https://asp.net-hacker.rocks/2018/07/05/aspnetcore-ssl.html
  • https://dzone.com/articles/configuring-https-in-aspnet-core-21
  • https://www.c-sharpcorner.com/article/configuring-https-in-asp-net-core-2-1/
  • https://docs.microsoft.com/en-us/aspnet/core/security/enforcing-ssl?view=aspnetcore-2.1&tabs=visual-studio

  • 在调试时,我仍然没有看到任何使用 Ubuntu 正确设置证书的指南/教程。

    最佳答案

    好吧,自从我切换到 Manjaro 并且我拥有 related problems 后,我设法让它工作了要进行修复,在开发证书方面,两个发行版的步骤是相同的​​。

    步骤:

  • 首先,安装开发自签名证书的工具:dotnet tool install --global dotnet-dev-certs
  • 然后,您需要为每个 bash 实例导出 dotnet 工具的路径:export PATH="$PATH:/home/{your-username}/.dotnet/tools"
  • 注册开发自签名证书:dotnet dev-certs https
  • 就这样,你就可以用https调试了~~
  • 关于ubuntu - 如何在针对 UBUNTU 运行的 ASP.NET Core 2.1 应用程序中设置 HTTPS 证书?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53174077/

    相关文章:

    bash - 如何将 bash 命令输出到标准输出并同时通过管道输出到另一个命令?

    windows-phone-7 - 有什么方法可以在 Windows Phone 7 模拟器上使用自签名证书?

    security - 如何使用JAVA URL httpsconnection发送没有证书的https请求

    powershell - 无法使用Powershell从商店中删除证书

    ubuntu - Ubuntu 19.10 上的 OpenModelica

    ruby-on-rails - 套接字错误 : Failed to open TCP connection to rubygmes. 组织:443

    android - search.h-在 Android-tiff 4.0.1 上移植 libtiff 时没有这样的文件或目录

    php - 无法使用 simplexml 解析 https 上的 XML 文件

    java - SOAP Web服务需要在java中使用https协议(protocol)发送请求

    ios - SharePoint 2016 的解决方法,其中用户在使用 https 连接时无法从 Apple iOS 设备登录