Trying to automate IIS setup for my website using InnoSetup including setting up the SSL certificate.
I've been successful with creating the self-signed SSL cert using SelfSSL, so far everything works ok except that I'm not sure how to automate the last process of binding the SSL cert (created using SelfSSL) to my website.

Referring to the picture above, how can I use command line to tell IIS bind the SSL cert (which named "Testing" in this case) to my website?
P/S: There's another similar question here: How to assign a SSL Certificate to IIS7 Site from Command Prompt
But that requires the person who run the command to get hold of the certhash beforehand.
OK, so I just found a solution for myself using Powershell.
Here's the powershell script to retrieve the certhash:
$hostname = 'example.com';
$certhash = dir cert:localmachine\my | where {$_.Subject -eq "CN=$($hostname)"} | select -first 1 | select-object -ExpandProperty Thumbprint
With that certhash info, we can now proceed with netsh command to bind the sslcert to our site:
netsh http add sslcert ipport=0.0.0.0:443 certhash=$certhash appid="{00112233-4455-6677-8899-AABBCCDDEEFF}"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With