在没有 SNI 的情况下在 powershell 中创建 IIS 站点

Creating IIS Site in powershell without SNI

我正在尝试在 powershell 中创建一个 IIS 站点。我希望在没有 SNI 的情况下创建该站点。
我正在使用 iis 10,(Windows 2016 服务器)。

我可以使用 sslflags=1 使用 SNI 创建站点。但是当我尝试在没有 sni 的情况下创建时,我 运行 遇到了问题。

下面是我的片段

$SecurePassword = ConvertTo-SecureString "Somepassword" -AsPlainText -Force; 
Import-PfxCertificate -FilePath 'C:\certs\nt111trnch01.pfx' -CertStoreLocation Cert:\LocalMachine\My -Password $SecurePassword; 
Import-PfxCertificate -FilePath 'C:\certs\nt111trnch02.pfx' -CertStoreLocation Cert:\LocalMachine\My -Password $SecurePassword; 
Import-PfxCertificate -FilePath 'C:\certs\nt111trnch03.pfx' -CertStoreLocation Cert:\LocalMachine\My -Password $SecurePassword; 
Import-Module "WebAdministration"; 
New-Item IIS:\Sites\myProj -bindings @{protocol='https';bindingInformation='*:8080:nt111trnch01.sit.abcit';SslFlags=1} -PhysicalPath C:\site; 
New-WebBinding -Name "myProj" -Protocol https -HostHeader nt111trnch02.sit.abcit -Port 8080 -SslFlags 1; \
New-WebBinding -Name "myProj" -Protocol https -HostHeader nt111trnch03.sit.abcit -Port 8080 -SslFlags 1; \
New-Item -Path "IIS:\SslBindings\*!8080!nt111trnch01.sit.abcit" -Thumbprint 145300EC69B3448EE15A54DBCD54647AF8294611 -SslFlags 1; 
New-Item -Path "IIS:\SslBindings\*!8080!nt111trnch02.sit.abcit" -Thumbprint 86C1CD3660F9810DB30CB2E312E197C898I26253 -SslFlags 1; 
New-Item -Path "IIS:\SslBindings\*!8080!nt111trnch03.sit.abcit" -Thumbprint 0C7888C0615615997DB6F9DA9E9A03E4671E3BAD -SslFlags 1; 
New-Item C:\site\myProj -type directory

注意:我可以创建具有单一证书且没有 SNI 的站点。但是绑定多个证书会导致问题。

提前致谢

更新 1 我将所有 SslFlags vlaue 更改为 0。 现在我收到这个错误。

New-Item : Cannot create a file when that file already exists
At line:12 char:2
+     New-Item -Path "IIS:\SslBindings\*!8080!nt111trnch02.sit.abci...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-Item], Win32Exception
    + FullyQualifiedErrorId : System.ComponentModel.Win32Exception,Microsoft.PowerShell.Commands.NewItemCommand

WARNING: Binding host name 'nt111trnch03.sit.abcit' is not equals to certificate subject name 'CN=nt111trnch03.sit.swcsit, OU=IT Services, O=Mycity 
Company, L=Mycity, S=State, C=Country'. Client may not be able to connect to the site using HTTPS protocol.
New-Item : Cannot create a file when that file already exists
At line:13 char:2
+     New-Item -Path "IIS:\SslBindings\*!8080!nt111trnch03.sit.abci ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-Item], Win32Exception
    + FullyQualifiedErrorId : System.ComponentModel.Win32Exception,Microsoft.PowerShell.Commands.NewItemCommand

我去检查了 IIS UI。 我可以看到三个绑定,但所有 3 个绑定都只使用第一个证书。我认为这是因为上面的错误。

我能找到解决办法。 我做了 IP bindng 让它工作。不确定这样是否正确。

我绑定服务器B的IP到服务器B的证书,服务器C的IP到服务器C的证书,所有的IP(*)到服务器A的证书。

不确定这是否正确,或者我是否应该将 IP 绑定到他们各自的证书。但这是有效的。已验证 Netscaler 能够在所有 3 台服务器上进行 SSL 握手

New-Item IIS:\Sites\myproj-bindings @{protocol='https';bindingInformation='*:8080:nt111trnch01.abcit.sit';SslFlags=0} -PhysicalPath C:\site; 
    New-WebBinding -Name "myproj" -Protocol https -HostHeader nt111trnch02.abcit.sit-IP 10.17.193.235 -Port 8080 -SslFlags 0; 
    New-WebBinding -Name "myproj" -Protocol https -HostHeader nt111trnch03.abcit.sit-IP 10.16.193.237 -Port 8080 -SslFlags 0; 
    New-Item -Path "IIS:\SslBindings\*!8080!nt111trnch01.abcit.sit" -Thumbprint 145300EC69B3448EE15A54DBCD54647AF8294611 -SslFlags 0; 
    New-Item -Path "IIS:\SslBindings.16.193.235!8080!nt111trnch02.abcit.sit" -Thumbprint 86C1CD3660F9810DB30CB2E312E197C898I26253 -SslFlags 0; 
    New-Item -Path "IIS:\SslBindings.16.193.237!8080!nt111trnch03.abcit.sit" -Thumbprint 0C7888C0615615997DB6F9DA9E9A03E4671E3BAD -SslFlags 0; 

如果这不是正确的方法,请告诉我。

谢谢。