Reputation: 1336
I have an ASP.NET Core Web Hosting Project which is deployed as a Window Service. I can access it in Browser with
http://localhost:5000/api/...
My question is how can I call to this service with HTTPS, like:
https://localhost:5000/api/...
I tried to add a certificate to port 5000, using this command:
netsh http add sslcert ipport=0.0.0.0:5000 certhash=myhash appid={myappid} clientcertnegotiation=enable
but it didn't work, the url cannot be found. Any idea? Thanks for your help.
Upvotes: 0
Views: 47
Reputation: 40938
ASP.NET Core projects that are hosted in a Windows Service use Kestrel as the web server.
According to this, Kestrel will listen on http://localhost:5001
by default, but only "when a local development certificate is present". That's not something you would want to use for production anyway.
The only way to specify the correct certificate to use, is to modify the code, which would look something like this (in Startup.cs):
.UseKestrel(options => {
options.UseHttps(certificateFileName, certificatePassword);
}
If you absolutely cannot modify the code, then you will have to use a proxy. One way to do that is to use the URL Rewrite feature of IIS. Instructions are here: Setup IIS with URL Rewrite as a reverse proxy for real world apps
Upvotes: 1