Programmaticaly add centralized SSL certificate store with APPCMD

484 Views Asked by At

I am creating a webinterface in PHP for basic updates to websites in IIS. One part is to add a new website and add the correct binding. I use the following commands to add a binding:

appcmd add site /name:"sitename" /bindings:"http://example.com:80" /physicalPath:"d:\websites"
appcmd set site /site.name:"sitename" /+bindings.[protocol='https',sslflags='3',bindingInformation='*:443:example.com']

I use the SSL Flag 3 to use the centralized SSL certificate store as specified in the Microsoft Binding docs

Everything seems to work fine as the site is added with both bindings and HTTP works. When I use HTTPS however, it keeps giving a connection reset error.

The only way to fix this is to open the bindings in IIS Manager, change something in any SSL binding without saving and change it back, just to make the "Ok" button available and press it. (EG: Port to 442 and back to 443) Nothing has changed in the actual settings and there are no changes to applicationHost.config.

After doing this, it all works.

What I tried without succes:

  1. iisreset command, no change
  2. start/stop/restart website
  3. start/stop/restart server
  4. reboot server
  5. tried several different servers

What could the binding dialog be doing that fixes this weird problem?

0

There are 0 best solutions below