Powershell - 使用共享证书添加SSL绑定 [英] Powershell - Add SSL binding using shared certificate
问题描述
我使用以下代码将证书链接到我添加的SSL绑定
I am using following code to link certificate to SSL binding that I have 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
此工作正常,没有任何错误。运行此操作后,如果我从IIS管理器打开该网站的绑定UI,我看不到任何附加到绑定的证书。我在这里遗漏了什么吗?
This works fine without any errors. After running this, if I open bindings UI for that website from IIS manager I do not see any certificate attached to the binding. Am I missing anything here?
在类似的主题上,如果我在两个网站之间使用共享证书,我需要注意什么才能确保添加/删除ssl绑定工作?我可以看到以下问题从IIS管理器UI执行此操作
On a similar topic, if I am using a shared certificate between two websites, what care do I need to take in order to ensure that adding/removing ssl bindings work? I can see following problems where doing this from IIS Manager UI
- 添加第二个绑定时,它会发出警告,说证书已被其他网站使用。我仍然继续前进,一切正常,不确定幕后发生了什么。
- 删除绑定时,会发出警告,说明证书用于其他绑定并删除此绑定会使其他绑定无法使用。即使在这种情况下,我继续,其他网站似乎工作正常
推荐答案
Get-Item期望Thumbprint的字符串值。希望这可以帮助。
Get-Item expects String Value of Thumbprint. 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
对于其他两个问题,HTTPS绑定是IP + SSLCertificate。因此,如果您想使用共享证书,请尝试为每个绑定使用唯一IP,这样做不会给您任何警告。
For the Other two Question, HTTPS Binding is IP+SSLCertificate. So if you want to use Shared Certificate try and use Unique IP for each Binding, doing so will not give you any Warning.
这篇关于Powershell - 使用共享证书添加SSL绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!