首页 > 系统服务 > 详细

How to create a Self-Signed Certificate using Powershell

时间:2020-05-28 09:04:16      阅读:51      评论:0      收藏:0      [点我收藏+]

Run the New-SelfSignedCertificate cmdlet as shown below to add a certificate to the local store on PC, replacing testcert.petri.com with the full qualified domain name(FQDN) that you‘d like to see.

> $cert = New-SelfSignedCertificate -certstorelocation cert:\localmachine\my -dnsname testcert.petri.com

The next step is to export a self-signed certificate.

> $pwd = ConvertTo-SecureString -String ‘passw0rd!’ -Force -AsPlainText

Now we can export a self-signed certificate using Export-PfxCertificate cmdlet. Use the password($pwd) created above, and create an additional string($path), which specifies the path to the certificate created with New-SelfSignedCertificate cmdlet.

> $path = ‘cert:\localMachine\my\‘ + $cert.thumbprint Export-PfxCertificate -cert $path -FilePath c:\temp\cert.pfx -Password $pwd

NOTE: the c:\temp directory, or whatever the directory you specify in the -FilePath parameter, must already existed.

How to create a Self-Signed Certificate using Powershell

原文:https://www.cnblogs.com/matt1985/p/12977897.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!