生成自签名证书
New-SelfSignedCertificate -CertStoreLocation Cert:\LocalMachine\My\ -DnsName "tflex.intranet.cnb"
导出并保存自签名证书
$certPwd = ConvertTo-SecureString -String ‘dipdev’ -Force -AsPlainText$thumbprint = '7B709651178E81109132FFCB3C28229996F08040'$cerPath = Get-Item Cert:\LocalMachine\My$thumbprintExport-PfxCertificate -Cert $cerPath -Force d:\tflex.intranet.cnb.pfx -Password $certPwd
仅导出公钥证书
Export-Certificate -Cert $cerPath -FilePath d:\tflex.intranet.cnb.cer
IIS 网站添加 SSL 证书
Get-Website -Name 'WordDedup.Html' | Get-WebBindingNew-WebBinding -Name "WordDedup.Html" -Protocol https -Port 443 -IPAddress * -HostHeader tflex.intranet.cnb -SslFlags 1
绑定 ssl 证书
$cert = Get-Item Cert:\LocalMachine\My$thumbprintNew-Item -Path IIS:\SslBindings!443!tflex.intranet.cnb -Value $cert -SSLFlags 1
安装根证书
Import-Certificate D:\tflex.intranet.cnb.cer -CertStoreLocation Cert:\CurrentUser\Root\
参考
PowerShell 生成自签名证书并绑定到 IIS