Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binding an SSL certificate to a port programmatically

I'm working on a self-hosted WCF service for which encrypted communications is an option. Everything works fine when a certificate is already bound to the port as described here.

However, I want to avoid asking the user to run a command line tool. Is there a way the binding can be done programmatically? Perhaps using WMI?

like image 605
dmo Avatar asked Nov 09 '09 17:11

dmo


People also ask

Is SSL certificate tied to a port?

Today, we'll answer one of the most common questions we get: “What port does SSL use?” Or, to put it other way that people ask: what are some of the most common SSL certificate port numbers that are used?” And the answer is none. SSL/TLS does not itself use any port — HTTPS uses port 443.


1 Answers

I believe the way to create an HTTP.SYS namespace reservation is through the HttpSetServiceConfiguration() unmanaged API; so you'll need some P/Invoke for that. There's some sample code that might be useful in one of Keith Brown's MSDN columns.

like image 76
tomasr Avatar answered Sep 23 '22 17:09

tomasr