Skip to content
This repository has been archived by the owner on Nov 21, 2018. It is now read-only.

Provide a nice error message when the HTTPS certificate is not configured for the current environment #83

Closed
danroth27 opened this issue Apr 28, 2017 · 3 comments
Assignees

Comments

@danroth27
Copy link
Member

Currently if you have a kestrel endpoint configured with a named certificate that isn't configured for the current environment you get an exception telling you that the certificate is missing. We should handle this exception and provide a reasonable error message to the user.

Current behavior:

~\Desktop\templates2\mvc-individual> $env:ASPNETCORE_ENVIRONMENT=""
~\Desktop\templates2\mvc-individual> dotnet run

Unhandled Exception: System.InvalidOperationException: No certificate named HTTPS found in configuration
   at Microsoft.AspNetCore.KestrelServerOptionsSetup.<>c__DisplayClass4_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, Dictionary`2 certificates)
   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.Extensions.Options.LegacyOptionsCache`1.get_Value()
   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 mvc_individual.Program.BuildWebHost(String[] args)
   at mvc_individual.Program.Main(String[] args)

Proposed behavior:

~\Desktop\templates2\mvc-individual> $env:ASPNETCORE_ENVIRONMENT=""
~\Desktop\templates2\mvc-individual> dotnet run

No certificate named HTTPS found in configuration for the current environment (Production). For information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.
@danroth27
Copy link
Member Author

@muratg Can we get this in for preview1?

@Eilon Eilon added this to the 2.0.0-preview1 milestone May 2, 2017
@Eilon
Copy link
Member

Eilon commented May 2, 2017

Yeah definitely should get in for preview1.

@muratg - can you assign?

@Eilon
Copy link
Member

Eilon commented May 2, 2017

@CesarBS - BTW the FWLink in the error message is already the right one to use (Dan just created it).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants