【发布时间】:2018-11-26 23:17:05
【问题描述】:
当我运行 Windows 更新并 sysprep 我的 Amazon EC2 实例 (Windows Server 2016) 时,我必须创建一个新的自签名证书。然后我可以在 Management Service 屏幕中选择 SSL 证书(我将其命名为 WebDeploy)。我已经知道如何从 Windows Powershell 创建 SSL 证书,但我必须从屏幕截图的下拉列表中选择 SSL 证书。如何从命令行设置 SSL 证书?
以下是我尝试过但不起作用的方法 - 我能够避免错误,但没有一个错误允许 WebDeploy 在我没有进入 IIS 管理器屏幕并手动选择下拉列表的情况下工作。
Stop-Service wmsvc
$strGuid = New-Guid
Import-Module WebAdministration
Remove-Item -Path IIS:\SslBindings\0.0.0.0!8172
Get-Item -Path "cert:\localmachine\my\$strHashThumbprint" | New-Item -Path
IIS:\SslBindings\0.0.0.0!8172
Start-Service wmsvc
而且,这也没用:
Stop-Service wmsvc
netsh http delete sslcert ipport=0.0.0.0:8172
netsh http add sslcert ipport=0.0.0.0:8172 certhash=$strHashThumbprint appid=`{$strGuid`} certstorename="MY" sslctlstorename="MY"
Start-Service wmsvc
最后,这没有用:
Stop-Service wmsvc
Add-NetIPHttpsCertBinding -IpPort "0.0.0.0:8172" -CertificateHash $strHash -CertificateStoreName "My" -ApplicationId "{$strGuid}" -NullEncryption $false
Start-Service wmsvc
【问题讨论】:
标签: powershell iis ssl-certificate webdeploy