IIS - Install SSL Certificate via Shell or Prompt
This is an addition to the installation manual for IIS. Only use this manual when installing the certificate via the GUI is not working.
Install via PowerShell
- Open PowerShell and search for the thumbprint of the certificate you wish to use with the following command:
Get-ChildItem -path cert:\LocalMachine\My
Copy and paste the thumbprint in a text editor, you will need to use it later.
- Create a new https binding on your site, you can do this by using the following command:
New-WebBinding -Name "Default Web Site" -IP "*" -Port 443 -Protocol https
Do not forget to change the name of the site and/or IP to your own.
- Assign the certificate to the IP address of the site, or use 0.0.0.0 when you want to bind it to all your sites. Use the following command:
get-item cert:\LocalMachine\MY\7ABF581E134280162AFFFC81E62011787B3B19B5 | new-item 0.0.0.0!443
Do not forget to change the thumbprint to your own.
Install via Command Prompt
- Open the command prompt and use the following command:
appcmd set site /site.name: string /+bindings. [protocol=' string ',bindingInformation=' string ']
- Variable site.name should be replaced with the name of the site to which you wish to add a binding. Variable protocol string represents the protocol you intend to use, and binding information is a combination of the IP-address and the host header.
- To give an example: the following command should be used to create a HTTPS binding for a site called Test for all IP-addresses on port 443 without a host header:
appcmd set site /site.name: Test /+bindings.[protocol='https',bindingInformation='*:443:']