0

I can create a self signed certificate with PowerShell:

$cert = New-SelfSignedCertificate –DnsName www.test.com -CertStoreLocation “cert:\LocalMachine\My”

I also can create bindings for my site:

New-WebBinding -Name "Test" -IPAddress "*" -Protocol "https" -Port 443 -HostHeader www.test.com -SslFlags 1

However based on the documentation New-WebBinding has no parameter which accepts a certificate see: New-WebBinding documentation

Question

How can I properly create the https binding which is using the created certificate?

1 Answer 1

1

From this related question. Replace 127.0.0.1 with your IP address:

Import-Module Webadministration
$IPAddress = '127.0.0.1' #your IIS server IP address
New-WebBinding -Name "Default Web Site" -Protocol "https" -IPAddress $IPAddress -Port 443 -HostHeader "www.test.com"
$SSLCert = Get-ChildItem –Path "cert:\LocalMachine\My" | 
  Where-Object {$_.subject -like 'cn=www.test.com*'}
New-Item "IIS:SslBindings\$IPAddress!443" -value $SSLCert 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.