【问题标题】:Creating IIS Site in powershell without SNI在没有 SNI 的 powershell 中创建 IIS 站点
【发布时间】: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


【解决方案1】:

我能够找到解决方案。 我做了 IP 绑定以使其正常工作。不知道是不是正确的方法。

我将服务器 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\10.16.193.235!8080!nt111trnch02.abcit.sit" -Thumbprint 86C1CD3660F9810DB30CB2E312E197C898I26253 -SslFlags 0; 
    New-Item -Path "IIS:\SslBindings\10.16.193.237!8080!nt111trnch03.abcit.sit" -Thumbprint 0C7888C0615615997DB6F9DA9E9A03E4671E3BAD -SslFlags 0; 

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

谢谢。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-08-09
    • 1970-01-01
    • 2013-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多