2

Powershell申请自签名证书

 2 years ago
source link: https://blog.51cto.com/gaowenlong/5590860
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Powershell申请自签名证书

精选 原创

高文龙 2022-08-18 17:23:19 博主文章分类:Powershell ©著作权

文章标签 签名证书 文章分类 Windows 系统/运维 阅读数263

说到自签名证书,相信大家应该会经常使用openssl进行申请,但是用powershell的还是比较少的,今天主要介绍使用Powershell来申请一个自签名证书,具体见下:

1.提交申请

$mycert = New-SelfSignedCertificate -DnsName "DomainName" -CertStoreLocation "cert:\CurrentUser\My" -NotAfter (Get-Date).AddYears(5) -KeySpec KeyExchange

2.导出Cer格式的证书文件

$mycert | Export-Certificate -FilePath d:\mycert.cer

3.导出pfx格式的证书文件

因为PFX格式自带证书,所以我们需要指定一个密码;

$mycert | Export-PfxCertificate -FilePath d:\mycert.pfx -Password $(ConvertTo-SecureString -String "123456" -AsPlainText -Force)

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK