2019年5月15日 星期三

使用Powershell在IIS上安裝SSL憑証

使用Powershell在IIS上安裝SSL憑証

使用Powershell在IIS上安裝SSL憑証

$securePfxPass = "你的密碼" | ConvertTo-SecureString -AsPlainText -Force
Import-PfxCertificate -Password $securePfxPass -CertStoreLocation Cert:\LocalMachine\My -FilePath c:\test.local.pfx   

#取得憑証指紋
$pfxThumbprint = (Get-PfxData -FilePath \test.local.pfx -Password $securePfxPass).EndEntityCertificates.Thumbprint

#新增 https 的繫結在 Default Web Site上
$binding = New-WebBinding -Name "Default Web Site" -Protocol https -IPAddress * -Port 443;
$binding = Get-WebBinding -Name "Default Web Site" -Protocol https;
# 綁定憑証 , 注意這裡的 "my" 是指憑証存放的Sotre , 不要亂改 , 指的是 Cert:\LocalMachine\My <-這個my
$binding.AddSslCertificate($pfxThumbprint, "my");

沒有留言:

張貼留言