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

查看:34
本文介绍了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:LocalMachineMy

然后尝试设置 SSL 绑定:

Then try to set the SSL bindings:

get-item 
      cert:LocalMachineMY$newCert.Thumbprint | 
      new-item -path IIS:SslBindings.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:LocalMachineMY$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:LocalMachineMy

# 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天全站免登陆