3

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.

enter image description here

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.

Community
  • 1
  • 1
Kagawa
  • 1,319
  • 2
  • 21
  • 33

1 Answers1

2

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}"
Kagawa
  • 1,319
  • 2
  • 21
  • 33