<div>I have an asp.net core API which uses both http and https. To enforce the certificate use, I added the following in my program.cs:</div> <div>```</div> <div> private static IWebHost BuildWebHost(IConfiguration configuration,
string[] args) =></div> <div> WebHost.CreateDefaultBuilder(args)</div> <div> </div> <div> .UseKestrel(options =></div> <div> {</div> <div> </div><div> options.ConfigureEndpointDefaults(listenOptions =></div> <div> {</div> <div> listenOptions.UseConnectionLogging();</div> <div> });</div><div> })</div> <div> .CaptureStartupErrors(false)</div> <div> .UseStartup<Startup>()</div> <div> </div> <div> .ConfigureKestrel(o =></div><div> {</div> <div> o.ConfigureHttpsDefaults(o =></div> <div> o.ClientCertificateMode =</div> <div> ClientCertificateMode.AllowCertificate);</div><div> })</div> <div> </div> <div>```</div> <div>If I run my app in my windows machine, everything works correctly. Nevertheless, when I run it in my docker desktop or even in an ubuntu machine I am
not able to call my https endpoint and I am getting a "ERR_CONNECTION_CLOSED". I am still able to call my http endpoint. In my docker compose ?I am setting correctly all the parameters:</div> <div> </div> <div>```</div> <div>environment:</div><div> - ASPNETCORE_ENVIRONMENT=Development</div> <div> - ASPNETCORE_URLS=https://+:443;http://+:80;https://+;http://+;</div> <div> - ASPNETCORE_HTTPS_PORT=5001</div> <div> - ASPNETCORE_Kestrel__Certificates__Default__Password=jtHxcTN</div><div> - ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx</div> <div> volumes:</div> <div> - ~/.aspnet/https:/https:ro </div> <div>```</div> <div>I even tried to create
a new certificate on my ubuntu using openssl but I am still having the same problem.</div> <div>PS: If I comment the line:</div> <div>```</div> <div> </div> <div>.ConfigureKestrel(o =></div> <div> {</div> <div> o.ConfigureHttpsDefaults(o =></div> <div> o.ClientCertificateMode =</div> <div> ClientCertificateMode.AllowCertificate);</div> <div> })</div> <div>```</div> <div>I am able to call my https endpoint, but no certificate is sent to the server.</div> <div>Any help ?</div> <div>Thank you </div> <div></div>
↧