aspnet / Hosting

[Archived] Code for hosting and starting up an ASP.NET Core application. Project moved to https://github.com/aspnet/Extensions and https://github.com/aspnet/AspNetCore
Apache License 2.0
552 stars 312 forks source link

Certificate for hosting in Windows Service #1573

Closed Edward-Zhou closed 5 years ago

Edward-Zhou commented 5 years ago

I follow this document Host ASP.NET Core in a Windows Service. After starting the service with sc start MyService, it only works for http, it did not redirect to https as this document indicates.

Then I try to configure the urls directly by

return WebHost.CreateDefaultBuilder(args) .ConfigureAppConfiguration((context, config) => { // Configure the app here. }) .UseUrls("http://localhost:5000","https://localhost:5001") The service will fail to start, and check the application log, it says that it fail to find the asp.net core dev certificate.

My current solution is running the service under my own user account.

But, I am wondering how to run the service under local system account. I already check asp.net core dev certificate is installed under Computer/Personal store.

Is there anything could be done from aspnet/Hosting or we should add more description on the Host ASP.NET Core in a Windows Service

Tratcher commented 5 years ago

The local system account uses a different certificate store. The dev cert isn't intended for that scenario. You should create a certificate, deploy it with the app, and load it directly.

@guardrex that https link in Windows Services is misleading them.