本文完全参考Microsoft的文档: 为程序包签名创建证书。
1.创建证书
打开PowerShell执行:
New-SelfSignedCertificate -Type Custom -Subject "CN=Contoso Software, O=Contoso Corporation, C=US" -KeyUsage DigitalSignature -FriendlyName "这里填写名称" -CertStoreLocation "Cert:\CurrentUser\My" -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.3", "2.5.29.19={text}")
PowerShell
导出:
$password = ConvertTo-SecureString -String 密码 -Force -AsPlainText
Export-PfxCertificate -cert "Cert:\CurrentUser\My\这里填写humbprint值" -FilePath C:\证书.pfx -Password $password
Export-PfxCertificate -cert "Cert:\CurrentUser\My\这里填写humbprint值" -FilePath C:\证书.pfx -Password $password
PowerShell
需要自行修改指令内容,其中密码指的是导出的.pfx证书的密码。
随后证书会被导出的位置在C:\证书.pfx
。
2.信任该证书
直接打开刚才生成的.pfx文件.
第1步选择本地计算机
,第3步需要输入.pfx证书的密码,第4步选择将所有证书都放入下列存储
并浏览选择受信任的根证书颁发机构
即可。