为什么我的带有SSL的Docker容器不起作用?

发布于 2025-02-05 07:51:45 字数 3824 浏览 1 评论 0原文

我的startup.cs适合https。我将其用于Windows Server。但是我想实施码头技术。我在没有HTTP的情况下实现了它。在我通过https之后,它不再起作用。这是我的docker run命令=>

docker run --name containername -p 8081:80 -p 8082:443 -e ASPNETCORE_URLS="https://+;http://+" -e ASPNETCORE_HTTPS_PORT=8082 -e ASPNETCORE_Kestrel__Certificates__Default__Password="mypass" -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/myssl.pfx -v rbpc\.dotnet\https -e DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false -d username/repositoryname:versionname

这是我在Docker CLI =&GT上的错误;

crit: Microsoft.AspNetCore.Server.Kestrel[0]

      Unable to start Kestrel.

      Interop+Crypto+OpenSslCryptographicException: error:2006D080:BIO routines:BIO_new_file:no such file

         at Interop.Crypto.CheckValidOpenSslHandle(SafeHandle handle)

         at Internal.Cryptography.Pal.OpenSslX509CertificateReader.FromFile(String fileName, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags)

         at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(String fileName, String password, X509KeyStorageFlags keyStorageFlags)

         at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(String fileName, String password)

         at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Certificates.CertificateConfigLoader.LoadCertificate(CertificateConfig certInfo, String endpointName)

         at Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.LoadDefaultCert()

         at Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.Reload()

         at Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.Load()

         at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.BindAsync(CancellationToken cancellationToken)

         at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)

Unhandled exception. Interop+Crypto+OpenSslCryptographicException: error:2006D080:BIO routines:BIO_new_file:no such file

   at Interop.Crypto.CheckValidOpenSslHandle(SafeHandle handle)

   at Internal.Cryptography.Pal.OpenSslX509CertificateReader.FromFile(String fileName, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags)

   at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(String fileName, String password, X509KeyStorageFlags keyStorageFlags)

   at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(String fileName, String password)

   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Certificates.CertificateConfigLoader.LoadCertificate(CertificateConfig certInfo, String endpointName)

   at Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.LoadDefaultCert()

   at Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.Reload()

   at Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.Load()

   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.BindAsync(CancellationToken cancellationToken)

   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)

   at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)

   at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)

   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)

   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)

   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)

   at MyWebApi.Program.Main(String[] args) in /src/MyWebApi/Program.cs:line 16

My startup.cs has suitable to https. I used it into Windows Server. But i want to implement docker technology. I have achieved it without https. After im passing https it did not work anymore. Here is my docker run command =>

docker run --name containername -p 8081:80 -p 8082:443 -e ASPNETCORE_URLS="https://+;http://+" -e ASPNETCORE_HTTPS_PORT=8082 -e ASPNETCORE_Kestrel__Certificates__Default__Password="mypass" -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/myssl.pfx -v rbpc\.dotnet\https -e DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false -d username/repositoryname:versionname

This is my errors on docker cli =>

crit: Microsoft.AspNetCore.Server.Kestrel[0]

      Unable to start Kestrel.

      Interop+Crypto+OpenSslCryptographicException: error:2006D080:BIO routines:BIO_new_file:no such file

         at Interop.Crypto.CheckValidOpenSslHandle(SafeHandle handle)

         at Internal.Cryptography.Pal.OpenSslX509CertificateReader.FromFile(String fileName, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags)

         at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(String fileName, String password, X509KeyStorageFlags keyStorageFlags)

         at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(String fileName, String password)

         at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Certificates.CertificateConfigLoader.LoadCertificate(CertificateConfig certInfo, String endpointName)

         at Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.LoadDefaultCert()

         at Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.Reload()

         at Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.Load()

         at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.BindAsync(CancellationToken cancellationToken)

         at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)

Unhandled exception. Interop+Crypto+OpenSslCryptographicException: error:2006D080:BIO routines:BIO_new_file:no such file

   at Interop.Crypto.CheckValidOpenSslHandle(SafeHandle handle)

   at Internal.Cryptography.Pal.OpenSslX509CertificateReader.FromFile(String fileName, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags)

   at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(String fileName, String password, X509KeyStorageFlags keyStorageFlags)

   at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(String fileName, String password)

   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Certificates.CertificateConfigLoader.LoadCertificate(CertificateConfig certInfo, String endpointName)

   at Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.LoadDefaultCert()

   at Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.Reload()

   at Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.Load()

   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.BindAsync(CancellationToken cancellationToken)

   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)

   at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)

   at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)

   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)

   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)

   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)

   at MyWebApi.Program.Main(String[] args) in /src/MyWebApi/Program.cs:line 16

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

李白 2025-02-12 07:51:45

使用- 用户ContainerAdministrator应解决问题。

Using --user ContainerAdministrator should fix the issue.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文