docker image netstandard2.0 failed to start due to unable to configure HTTPS endpoint #271

Closed
opened 2025-12-29 15:19:29 +01:00 by adam · 7 comments
Owner

Originally created by @yunj on GitHub (May 16, 2020).

Originally assigned to: @StefH on GitHub.

Here documents that when using netstandard, WireMock.Net uses a self signed certificate to host https urls. But when docker run sheyenrath/wiremock.net:1.2.6 with --Urls http://localhost:9091 https://localhost:9443, it failed to start due to the error Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found.

05/15/2020 21:23:38 [Debug] : WireMock.Net server settings {
  "Port": null,
  "UseSSL": null,
  "StartAdminInterface": true,
  "ReadStaticMappings": true,
  "WatchStaticMappings": false,
  "WatchStaticMappingsInSubdirectories": false,
  "ProxyAndRecordSettings": null,
  "Urls": [
    "http://localhost:9091",
    "https://localhost:9443"
  ],
  "StartTimeout": 10000,
  "AllowPartialMapping": false,
  "AdminUsername": null,
  "AdminPassword": null,
  "RequestLogExpirationDuration": null,
  "MaxRequestLogCount": null,
  "AllowCSharpCodeMatcher": false,
  "AllowBodyForAllHttpMethods": false,
  "AllowOnlyDefinedHttpStatusCodeInResponse": false,
  "DisableJsonBodyParsing": false,
  "DisableRequestBodyDecompressing": null
}
05/15/2020 21:23:39 [Info] : WireMock.Net server using netstandard2.0
Application startup exception: System.InvalidOperationException: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate c
ould not be found.
To generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS only) run 'dotnet dev-certs https --trust'.
For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.
   at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions, Action`1 configureOptions)
   at WireMock.Owin.AspNetCoreSelfHost.<>c.<StartAsync>b__19_3(ListenOptions listenOptions)
   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerOptions.Listen(IPEndPoint endPoint, Action`1 configure)
   at WireMock.Owin.AspNetCoreSelfHost.<StartAsync>b__19_2(KestrelServerOptions options)
   at Microsoft.Extensions.Options.OptionsFactory`1.Create(String name)
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.CreateServiceContext(IOptions`1 options, ILoggerFactory loggerFactory)
   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer..ctor(IOptions`1 options, ITransportFactory transportFactory, ILoggerFactory loggerFactory)
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureServer()
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()

Does it mean I need to build a new image with certificate installed? Thanks a lot!

Originally created by @yunj on GitHub (May 16, 2020). Originally assigned to: @StefH on GitHub. [Here](https://github.com/WireMock-Net/WireMock.Net/wiki/Using-HTTPS-%28SSL%29#http-ssl) documents that when using netstandard, WireMock.Net uses a self signed certificate to host https urls. But when docker run `sheyenrath/wiremock.net:1.2.6` with `--Urls http://localhost:9091 https://localhost:9443`, it failed to start due to the error **Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found**. ``` 05/15/2020 21:23:38 [Debug] : WireMock.Net server settings { "Port": null, "UseSSL": null, "StartAdminInterface": true, "ReadStaticMappings": true, "WatchStaticMappings": false, "WatchStaticMappingsInSubdirectories": false, "ProxyAndRecordSettings": null, "Urls": [ "http://localhost:9091", "https://localhost:9443" ], "StartTimeout": 10000, "AllowPartialMapping": false, "AdminUsername": null, "AdminPassword": null, "RequestLogExpirationDuration": null, "MaxRequestLogCount": null, "AllowCSharpCodeMatcher": false, "AllowBodyForAllHttpMethods": false, "AllowOnlyDefinedHttpStatusCodeInResponse": false, "DisableJsonBodyParsing": false, "DisableRequestBodyDecompressing": null } 05/15/2020 21:23:39 [Info] : WireMock.Net server using netstandard2.0 Application startup exception: System.InvalidOperationException: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate c ould not be found. To generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS only) run 'dotnet dev-certs https --trust'. For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054. at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions, Action`1 configureOptions) at WireMock.Owin.AspNetCoreSelfHost.<>c.<StartAsync>b__19_3(ListenOptions listenOptions) at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerOptions.Listen(IPEndPoint endPoint, Action`1 configure) at WireMock.Owin.AspNetCoreSelfHost.<StartAsync>b__19_2(KestrelServerOptions options) at Microsoft.Extensions.Options.OptionsFactory`1.Create(String name) at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode) at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor) at System.Lazy`1.CreateValue() at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.CreateServiceContext(IOptions`1 options, ILoggerFactory loggerFactory) at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer..ctor(IOptions`1 options, ITransportFactory transportFactory, ILoggerFactory loggerFactory) --- End of stack trace from previous location where exception was thrown --- at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEngineScope scope) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider) at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureServer() at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication() ``` Does it mean I need to build a new image with certificate installed? Thanks a lot!
adam added the question label 2025-12-29 15:19:29 +01:00
adam closed this issue 2025-12-29 15:19:29 +01:00
Author
Owner

@StefH commented on GitHub (May 16, 2020):

What I normally do is just run and start the container in Azure with no additional port or url settings.
Only these parameters --StartAdminInterface true --AdminUsername xxx--AdminPassword xxx --UseSSL true --WireMockLogger WireMockConsoleLogger

When running in Azure I can access the service at http and https.

WireMock.Net uses a self signed certificate when running in your unit tests.

@StefH commented on GitHub (May 16, 2020): What I normally do is just run and start the container in Azure with no additional port or url settings. Only these parameters `--StartAdminInterface true --AdminUsername xxx--AdminPassword xxx --UseSSL true --WireMockLogger WireMockConsoleLogger` When running in Azure I can access the service at http and https. WireMock.Net uses a self signed certificate when running in your unit tests.
Author
Owner

@yunj commented on GitHub (May 16, 2020):

Hi @StefH , thanks very much for your reply.

I can only run the Wiremock.Net container on a normal computer. I tried --UseSSL but seems not working and the server settings show UseSSL:null.

PS C:\wiremock.net> docker run sheyenrath/wiremock.net:1.2.6 --StartAdminInterface true --UseSSL true --WireMockLogger WireMockConsoleLogger
05/16/2020 08:14:27 [Info] : WireMock.Net by Stef Heyenrath (https://github.com/WireMock-Net/WireMock.Net)
05/16/2020 08:14:28 [Debug] : WireMock.Net server settings {
  "Port": null,
  "UseSSL": null,
  "StartAdminInterface": true,
  "ReadStaticMappings": false,
  "WatchStaticMappings": false,
  "WatchStaticMappingsInSubdirectories": false,
  "ProxyAndRecordSettings": null,
  "Urls": [
    "http://*:80"
  ],
  "StartTimeout": 10000,
  "AllowPartialMapping": false,
  "AdminUsername": null,
  "AdminPassword": null,
  "RequestLogExpirationDuration": null,
  "MaxRequestLogCount": null,
  "AllowCSharpCodeMatcher": false,
  "AllowBodyForAllHttpMethods": false,
  "AllowOnlyDefinedHttpStatusCodeInResponse": false,
  "DisableJsonBodyParsing": false,
  "DisableRequestBodyDecompressing": null
}
05/16/2020 08:14:28 [Info] : WireMock.Net server using netstandard2.0
Hosting environment: Production
Content root path: /app/
Now listening on: http://0.0.0.0:80
05/16/2020 08:14:28 Press Ctrl+C to shut down
05/16/2020 08:14:28 WireMock.Net server running
@yunj commented on GitHub (May 16, 2020): Hi @StefH , thanks very much for your reply. I can only run the Wiremock.Net container on a normal computer. I tried `--UseSSL` but seems not working and the server settings show `UseSSL:null`. ``` PS C:\wiremock.net> docker run sheyenrath/wiremock.net:1.2.6 --StartAdminInterface true --UseSSL true --WireMockLogger WireMockConsoleLogger 05/16/2020 08:14:27 [Info] : WireMock.Net by Stef Heyenrath (https://github.com/WireMock-Net/WireMock.Net) 05/16/2020 08:14:28 [Debug] : WireMock.Net server settings { "Port": null, "UseSSL": null, "StartAdminInterface": true, "ReadStaticMappings": false, "WatchStaticMappings": false, "WatchStaticMappingsInSubdirectories": false, "ProxyAndRecordSettings": null, "Urls": [ "http://*:80" ], "StartTimeout": 10000, "AllowPartialMapping": false, "AdminUsername": null, "AdminPassword": null, "RequestLogExpirationDuration": null, "MaxRequestLogCount": null, "AllowCSharpCodeMatcher": false, "AllowBodyForAllHttpMethods": false, "AllowOnlyDefinedHttpStatusCodeInResponse": false, "DisableJsonBodyParsing": false, "DisableRequestBodyDecompressing": null } 05/16/2020 08:14:28 [Info] : WireMock.Net server using netstandard2.0 Hosting environment: Production Content root path: /app/ Now listening on: http://0.0.0.0:80 05/16/2020 08:14:28 Press Ctrl+C to shut down 05/16/2020 08:14:28 WireMock.Net server running ```
Author
Owner

@StefH commented on GitHub (May 16, 2020):

What you need to do is provide the URLs as you did before (--Urls http://localhost:9091 https://localhost:9443)

And then take a look at this article: https://www.vivienfabing.com/docker/2019/10/03/docker-aspnetcore-container-and-https.html
I think this describes how to solve your issue. However, I did not yet test this myself.

@StefH commented on GitHub (May 16, 2020): What you need to do is provide the URLs as you did before (`--Urls http://localhost:9091 https://localhost:9443`) And then take a look at this article: https://www.vivienfabing.com/docker/2019/10/03/docker-aspnetcore-container-and-https.html I think this describes how to solve your issue. However, I did not yet test this myself.
Author
Owner

@yunj commented on GitHub (May 21, 2020):

Thanks @StefH for your reply. For the container in Azure, what are the values for ASPNETCORE_URLS, ASPNETCORE_HTTPS_PORT, ASPNETCORE_Kestrel__Certificates__Default__Path?

@yunj commented on GitHub (May 21, 2020): Thanks @StefH for your reply. For the container in Azure, what are the values for `ASPNETCORE_URLS`, `ASPNETCORE_HTTPS_PORT`, `ASPNETCORE_Kestrel__Certificates__Default__Path`?
Author
Owner

@StefH commented on GitHub (May 21, 2020):

When deploying WireMock.Net to Azure, I just use this deployment:

image

steps:
- task: AzureRmWebAppDeployment@4
  displayName: 'Deploy Docker Container to Linux Web App'
  inputs:
    azureSubscription: '$(Parameters.ConnectedServiceName)'
    appType: '$(Parameters.WebAppKind)'
    WebAppName: '$(Parameters.WebAppName)'
    DockerNamespace: '$(Parameters.DockerNamespace)'
    DockerRepository: '$(Parameters.DockerRepository)'
    DockerImageTag: '$(Build.BuildId)'
    StartupCommand: '$(Parameters.StartupCommand)'

And the only things I provide are:
--StartAdminInterface true --AdminUsername xxx --AdminPassword xxx --UseSSL true --WireMockLogger WireMockConsoleLogger

Now I can access wiremock via https
Example:
https://wiremock-090dee8d-d6dc-4754-bd61-8372acd20ded.azurewebsites.net/

@StefH commented on GitHub (May 21, 2020): When deploying WireMock.Net to Azure, I just use this deployment: ![image](https://user-images.githubusercontent.com/249938/82561291-6a964a00-9b73-11ea-8ff2-7782cb3eab8b.png) ``` yml steps: - task: AzureRmWebAppDeployment@4 displayName: 'Deploy Docker Container to Linux Web App' inputs: azureSubscription: '$(Parameters.ConnectedServiceName)' appType: '$(Parameters.WebAppKind)' WebAppName: '$(Parameters.WebAppName)' DockerNamespace: '$(Parameters.DockerNamespace)' DockerRepository: '$(Parameters.DockerRepository)' DockerImageTag: '$(Build.BuildId)' StartupCommand: '$(Parameters.StartupCommand)' ``` And the only things I provide are: `--StartAdminInterface true --AdminUsername xxx --AdminPassword xxx --UseSSL true --WireMockLogger WireMockConsoleLogger` Now I can access wiremock via https Example: https://wiremock-090dee8d-d6dc-4754-bd61-8372acd20ded.azurewebsites.net/
Author
Owner

@StefH commented on GitHub (Jul 7, 2020):

@yunj
Does this answer your question?

@StefH commented on GitHub (Jul 7, 2020): @yunj Does this answer your question?
Author
Owner

@yunj commented on GitHub (Jul 9, 2020):

@StefH thanks very much. We decided to use http.

@yunj commented on GitHub (Jul 9, 2020): @StefH thanks very much. We decided to use http.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#271