mpe*_*n18 5 powershell certificate pki
我使用 powershell 应用程序部署工具包,我有一个脚本来安装一些 MSI。对于 MSI 之一,我有一个证书 ( cert.cer),我需要将其安装在每台机器的受信任发布者上。
在做了一些挖掘之后,我想出了这个:
certutil.exe -addstore TrustedPublisher cert.cer
certutil.exe -addstore root cert.cer
这不起作用,没有错误,只是仍然提示我必须接受来自不受信任的发布者的安装。
以管理员身份打开 PowerShell 并运行:
Import-Certificate -FilePath cert.cer -CertStoreLocation Cert:\LocalMachine\TrustedPublisher
Run Code Online (Sandbox Code Playgroud)
pas*_*sha -1
这对我有用,
$pfx = new-object System.Security.Cryptography.X509Certificates.X509Certificate2
$certPath = read-host "Certificate Path"
$pfxPass = read-host "Password" -assecurestring
$pfx.import($certPath,$pfxPass,"Exportable,PersistKeySet")
$store = new-object System.Security.Cryptography.X509Certificates.X509Store(
[System.Security.Cryptography.X509Certificates.StoreName]::TrustedPublisher,
"localmachine"
)
$store.open("MaxAllowed")
$store.add($pfx)
$store.close()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6085 次 |
| 最近记录: |