【发布时间】:2018-02-23 02:22:48
【问题描述】:
我正在尝试在 powershell 中创建一个 IIS 站点。我希望在没有 SNI 的情况下创建该站点。
我正在使用 iis 10,(Windows 2016 服务器)。
我可以使用 sslflags=1 创建带有 SNI 的站点。但是当我尝试在没有 sni 的情况下进行创建时,我遇到了问题。
下面是我的sn-p
$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 值更改为 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 个绑定都只使用第一个证书。我认为这是因为上面的错误。
【问题讨论】:
-
您似乎试图将 3 个 SSL 证书绑定到 3 个站点,在相同的 IP 和端口上。这不是您可以使用 SSL 做的事情 - 服务器不知道浏览器想要哪个站点,直到 之后 它使用证书来协商连接。 SNI 是为了解决这个问题而发明的,它允许使用多个证书,以便服务器知道使用哪个证书。您需要不同的 IP、不同的端口或 SNI 来执行此操作。
-
@TessellatingHeckler 我同意最初的帖子缺乏信息,我在尝试新场景时不断更新。我以为你在拖钓。谢谢你的信息。显然我们的 Netscaler 与 SNI 不兼容。因此,如果启用 SNI,我们的网站将无法工作。我们有一个站点将在 3 个服务器上运行,因此有 3 个证书。我在帖子中使用上述 sn-p 并在所有 3 台服务器上执行。我只是 IIS 的新手,也许我的方法有误
-
这是 SSL 技术限制,而不是 IIS 特定问题。我不知道 NetScaler,但 Citrix 文档看起来像 it's supported SNI for SSL offloading since version 9 所以也许你可以回答 NetScaler 上的 SSL 连接?每个站点的单独公共 IP 是处理此问题的正常方法,但如果您没有更多 IP 并且无法从您的 ISP 获得任何 IP,那么您就不能这样做。另一种选择可能是使用一个通配符证书
*.sit.abcit运行它们,这同样更昂贵。或者将 NetScaler 升级到固件 11.1。 -
谢谢。我们的团队确认他们拥有 Netscaler 11,我们需要 Netscaler 11.1 才能拥有 SNI。
标签: powershell iis sni