Asp.net-core 2.0 Cannot configure HTTPS endpoint

I have developed an application in asp.net-core 2.0 preview1. I developed it on windows with Visual Studio 2017.

Now I want to deploy it to Linux server using Docker.

I have created a Docker image on windows.

Docker file:

FROM microsoft/aspnetcore:2.0
ARG source
WORKDIR /app
EXPOSE 44305
COPY ${source:-obj/Docker/publish} .
ENTRYPOINT ["dotnet", "Application.Web.dll"]

      

After running the following commands:

dotnet build -o obj/Docker/publish -c Release
dotnet publish -o obj/Docker/publish -c Release
docker build -t testapi-api .

      

Then I described the image on a Linux server using Docker and ran it:

docker run -p 44305:80 --name api testapi-api

      

But I am getting the error:

Unhandled Exception: System.InvalidOperationException: Unable to configure HTTPS endpoint. For information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054. ---> System.Collections.Generic.KeyNotFoundException: No certificate named 'HTTPS' found in configuration for the current environment (Production).
       at Microsoft.AspNetCore.CertificateLoader.LoadSingle(String certificateName)
       at Microsoft.AspNetCore.CertificateLoader.Load(IConfigurationSection certificateConfiguration)
       at Microsoft.AspNetCore.KestrelServerOptionsSetup.<>c__DisplayClass6_0.<BindEndPoint>b__0(ListenOptions listenOptions)
       --- End of inner exception stack trace ---
       at Microsoft.AspNetCore.KestrelServerOptionsSetup.<>c__DisplayClass6_0.<BindEndPoint>b__0(ListenOptions listenOptions)
       at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerOptions.Listen(IPEndPoint endPoint, Action`1 configure)
       at Microsoft.AspNetCore.KestrelServerOptionsSetup.BindEndPoint(KestrelServerOptions options, IConfigurationSection endPoint, CertificateLoader certificateLoader)
       at Microsoft.AspNetCore.KestrelServerOptionsSetup.BindConfiguration(KestrelServerOptions options)
       at Microsoft.Extensions.Options.LegacyOptionsCache`1.CreateOptions()
       at System.Threading.LazyInitializer.EnsureInitializedCore[T](T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory)
       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 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProvider provider)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProvider provider)
       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()
       at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
       at XTrader.Web.Program.Main(String[] args) in C:\wamp64\www\app\Application.Web\Program.cs:line 17

      

I followed the instructions here but not sure if I did well.

Tried to create certificate.pfx

and add it to the project but it doesn't work.

If someone can help me figure out how to make it work in this case when deploying to linux server.

+3


source to share





All Articles