Search code examples
c#owinwebapi2self-host-webapi

.net webapi self hosted ssl


I would like to create a self hosted webapi that is reachable over https (ssl). I am a little bit confused because I see many different ways to do this. I read something about Karma and owin. As I know Owin is the current way to do this. Ao I implemented the first test with http and everything looks fine. But now I would like to use https. I read that you have to bind a ssl certificate to ip and port. To do this I should call netsh. But I have multiple customer machines where this service has to run. Is there any way to do it automatically in code? I mean why should I have to do it manually?


Solution

  • An SSL cert has to be bound to either a specified host name, or a specified IP address. So if you're installing on several machines, by definition, you'd need multiple SSL certs for your approach to work. You might be able to dump the cert files into a common folder and let your application sort out which one to apply, but you're going to need more than one.

    What'd be cool would be if you could call an appropriate API to tell Windows to generate a new cert at run-time!