Ziya Arslan
Ziya Arslan

Reputation: 131

Docker https problem unable to start Kestrel

I'm having a problem with the docker container. I'm trying to learn microservice architecture and unfortunately having a problem with docker. I made a research about how to solve that but non of the solutions helped me.

Here is my 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

my generated certificate is located in projectfolder/conf.d/https/dev_cert.pfx

Here is Docker Error.

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

I'm using mac os docker: Docker version 20.10.5, build 55c4c88

dotnet 5.0.301

Upvotes: 1

Views: 2883

Answers (1)

Ziya Arslan
Ziya Arslan

Reputation: 131

I solved that by removing

  • 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

Upvotes: 2

Related Questions