我正在使用以下代码将证书链接到我添加的 SSL 绑定(bind)
$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
这工作正常,没有任何错误。运行此命令后,如果我从 IIS 管理器打开该网站的绑定(bind) UI,我看不到任何附加到绑定(bind)的证书。我在这里遗漏了什么吗?
在类似的主题上,如果我在两个网站之间使用共享证书,我需要注意什么以确保添加/删除 ssl 绑定(bind)有效?从 IIS 管理器 UI 执行此操作时,我可以看到以下问题
- 添加第二个绑定(bind)时,它会发出警告说证书已被其他网站使用。我仍然继续前进,一切正常,但不确定幕后发生了什么。
- 删除绑定(bind)时,它会发出警告,指出证书已用于其他绑定(bind),删除此绑定(bind)会使其他绑定(bind)无法使用。即使在这种情况下,我也会继续,其他网站似乎工作正常
最佳答案
Get-Item 需要指纹的字符串值。希望这可以帮助。
$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
另外两个Question,HTTPS Binding是IP+SSLCertificate。因此,如果您想使用共享证书,请尝试为每个绑定(bind)使用唯一 IP,这样做不会给您任何警告。
关于Powershell - 使用共享证书添加 SSL 绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19120339/