Powershell 导入PFX证书


你能使用Get-PfxCertificate从PFX文件加载数字证书,然后用证书去签名脚本文件,例如:

$pfxpath = 'C:\PathToPfxFile\testcert.pfx'
$cert = Get-PfxCertificate -FilePath $pfxpath
$cert
Get-ChildItem -Path c:\myscripts -Filter *.ps1 | Set-AuthenticodeSignature -Certificate $cert

然而,Get-PfxCertificate 将使用交互式询问密码,这个密码是当你开始导出证书到PFX文件时要求输入的。

$pfxpath = 'C:\PathToPfxFile\testcert.pfx'
$password = 'topsecret'

Add-Type -AssemblyName System.Security
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
$cert.Import($pfxpath, $password, 'Exportable')
$cert

原文地址: Importing Certificates from PFX Files

本文链接: https://www.pstips.net/importing-certificates-from-pfx-files.html
请尊重原作者和编辑的辛勤劳动,欢迎转载,并注明出处!

发表评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注