【问题标题】:How to add created certificate to an IIS https binding using PowerShell如何使用 PowerShell 将创建的证书添加到 IIS https 绑定
【发布时间】:2019-01-26 04:41:39
【问题描述】:

我可以使用 PowerShell 创建自签名证书:

$cert = New-SelfSignedCertificate –DnsName www.test.com -CertStoreLocation “cert:\LocalMachine\My”

我还可以为我的网站创建绑定:

New-WebBinding -Name "Test" -IPAddress "*" -Protocol "https" -Port 443 -HostHeader www.test.com -SslFlags 1

但是根据文档 New-WebBinding 没有接受证书see: New-WebBinding documentation的参数

问题

如何正确创建使用已创建证书的 https 绑定?

【问题讨论】:

    标签: powershell iis ssl-certificate


    【解决方案1】:

    来自this related question。将 127.0.0.1 替换为您的 IP 地址:

    Import-Module Webadministration
    $IPAddress = '127.0.0.1' #your IIS server IP address
    New-WebBinding -Name "Default Web Site" -Protocol "https" -IPAddress $IPAddress -Port 443 -HostHeader "www.test.com"
    $SSLCert = Get-ChildItem –Path "cert:\LocalMachine\My" | 
      Where-Object {$_.subject -like 'cn=www.test.com*'}
    New-Item "IIS:SslBindings\$IPAddress!443" -value $SSLCert 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-07
      • 1970-01-01
      • 2023-03-13
      • 2018-11-07
      • 2021-02-18
      • 2014-05-28
      • 2016-04-16
      • 2015-11-30
      相关资源
      最近更新 更多