Powershell - Add SSL Binding Using a Common Certificate

I use the following code to bind a certificate with an SSL binding, which I added

$thumb = (Get-ChildItem cert:\LocalMachine\My | where-object { $_.Subject -like $wildCardSubject } | Select-Object -First 1).Thumbprint Push-Location IIS:\SslBindings Get-Item cert:\LocalMachine\My\$thumb | New-Item $ipAddress!$port Pop-Location 

This works fine without errors. After starting this, if I open the bindings user interface for this website from IIS Manager, I don’t see any certificate attached to the binding. Am I missing something here?

In a similar topic, if I use a common certificate between two websites, what care should I take to ensure that ssl bindings are added / removed? I see the following problems when this is done from the IIS Manager interface

  • When you add a second binding, it gives a warning that the certificate is already in use by another site. I am still continuing and everything is working, not sure what is going on behind the scenes.
  • When you remove a binding, it gives a warning that the certificate is used in another binding, and removing this binding will make it impossible to use other links. Even so, I continue, and the other site is working fine
+2
source share
1 answer

Get-Item expects a Thumbprint string value. Hope this helps.

 $Cert = dir cert:\localmachine\my | Where-Object {$_.Subject -like $CertSubject } $Thumb = $Cert.Thumbprint.ToString() Push-Location IIS:\SslBindings New-WebBinding -Name $WebSiteName -IP $IP -Port 443 -Protocol https Get-Item cert:\LocalMachine\MY\$strThumb | new-item $IP!443 Pop-Location 

For the other two issues, HTTPS binding is an IP + SSLC certificate. Therefore, if you want to use the Shared Certificate, try to use a unique IP address for each Binding, this will not give you any warnings.

+8
source

All Articles