使用 PowerShell 将 SSL 证书绑定到端口

Roy*_*ton 5 powershell

 $Thumbprint = (Get-ChildItem -Path Cert:\LocalMachine\My | Where-Object {$_.Subject -match "CN=appserver.domain.com"}).Thumbprint;

    $guid = [guid]::NewGuid()
    $certHash = $thumbprint
    $ip = "0.0.0.0" # This means all IP addresses
    $port = "8280" # the default HTTPS port

    "http add sslcert ipport=$($ip):$port certhash=$Thumbprint appid={$guid}" | netsh
Run Code Online (Sandbox Code Playgroud)

我从网上搜索得到这个,但它不起作用。当我运行它时,该条目并未创建。我正在检查netsh http show sslcert,那里什么也没有。

小智 4

如果您有 PowerShell 4.0+,则可以使用 Add-NetIPHttpsCertBinding

文档 + 示例https://technet.microsoft.com/itpro/powershell/windows/networktransition/add-netiphttpscertbinding