Powershell-在https绑定上设置SSL证书 [英] Powershell - Set SSL Certificate on https Binding

查看:172
本文介绍了Powershell-在https绑定上设置SSL证书的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用PowerShell在IIS站点上为自签名/本地证书设置SSL证书。

I am trying to use PowerShell to set the SSL certificate on an IIS site for a self signed/local certificate.

我创建证书:

$newCert = 
       New-SelfSignedCertificate 
       -DnsName www.mywebsite.ru 
       -CertStoreLocation cert:\LocalMachine\My

然后尝试设置SSL绑定:

Then try to set the SSL bindings:

get-item 
      cert:\LocalMachine\MY\$newCert.Thumbprint | 
      new-item -path IIS:\SslBindings\0.0.0.0!443

如这篇文章所示: http://www.iis.net/learn/manage/powershell/powershell-snap-in-configuring-ssl-with-the-iis-powershell-snap-in

也显示在这里:
PowerShell IIS7管理单元将SSL证书分配给https绑定

我也尝试过:

get-item 
      cert:\LocalMachine\MY\$newCert.Thumbprint | 
      new-item -path IIS:\SslBindings\*!443

否无效,在编辑网站绑定对话框中没有看到SSL证书设置。

To no avail, I'm not seeing the SSL Certificate set in the Edit Site Binding dialog.

有什么想法吗?

推荐答案

您必须将证书分配给特定站点。

You have to assign the certifcate to a specific site.

您可以使用 Get-WebBinding cmdlet并使用 AddSslCertificate 函数设置SSL证书:

You can retrieve the binding information of your site using the Get-WebBinding cmdlet and set the SSL Certificate using the AddSslCertificate function:

$siteName = 'mywebsite'
$dnsName = 'www.mywebsite.ru'

# create the ssl certificate
$newCert = New-SelfSignedCertificate -DnsName $dnsName -CertStoreLocation cert:\LocalMachine\My

# get the web binding of the site
$binding = Get-WebBinding -Name $siteName -Protocol "https"

# set the ssl certificate
$binding.AddSslCertificate($newCert.GetCertHashString(), "my")

这篇关于Powershell-在https绑定上设置SSL证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆