【问题标题】:Docker https problem unable to start KestrelDocker https问题无法启动Kestrel
【发布时间】:2023-03-23 13:16:01
【问题描述】:

我的 docker 容器有问题。我正在尝试学习微服务架构,但不幸的是 docker 遇到了问题。我对如何解决这个问题进行了研究,但没有一个解决方案对我有帮助。

这是我的 docker-compose.ovverride.yml:

version: '3.4'

services:
  sourcingdb:
    container_name: sourcingdb
    restart: always
    volumes:
      - ./data:/data/db
    ports:
      - "27017:27017"
  esourcing.products:
    container_name: esourcingproduct
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - ASPNETCORE_URLS=https://+:443;http://+:80
      - ASPNETCORE_Kestrel__Certificates__Default__Password=madison
      - ASPNETCORE_HTTPS_PORT=44311
      - ASPNETCORE_Kestrel__Certificates__Default__Path=/https/dev_cert.pfx
      - "ProductDatabaseSettings:ConnectionString=mongodb://sourcingdb:27017"
    depends_on:
      - sourcingdb
    ports:
      - "8000:80"
      - "443"
    volumes:
      - ~/.aspnet/https:/root/.aspnet/https:ro
      - ~/.microsoft/usersecrets:/root/.microsoft/usersecrets:ro

我生成的证书位于 projectfolder/conf.d/https/dev_cert.pfx

这是 Docker 错误。

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 ESourcing.Products.Program.Main(String[] args) in /src/src/Services/Products/ESourcing.Products/Program.cs:line 16

我正在使用 mac os docker: Docker 版本 20.10.5,构建 55c4c88

dotnet 5.0.301

【问题讨论】:

    标签: .net docker .net-core containers


    【解决方案1】:

    我通过删除解决了这个问题

    • ASPNETCORE_Kestrel__Certificates__Default__Password=madison
    • ASPNETCORE_HTTPS_PORT=44311
    • ASPNETCORE_Kestrel__Certificates__Default__Path=/https/dev_cert.pfx
    • ASPNETCORE_URLS=https://+:443;http://+:80

    【讨论】:

      猜你喜欢
      • 2020-04-20
      • 2022-01-07
      • 1970-01-01
      • 2021-12-12
      • 2021-02-04
      • 1970-01-01
      • 2023-02-01
      • 2017-01-03
      • 2019-02-08
      相关资源
      最近更新 更多