我如何使發布者憑證預設安裝到「受信任的發布者」中?

我如何使發布者憑證預設安裝到「受信任的發布者」中?

我在 PowerShell 中製作了一個憑證。第一個是根,第二個我想要發布者。

我將證書匯出到“*.pfx”文件,當我從該文件安裝時,根目錄被放入根資料夾並且很好,但第二個將進入公共而不是“受信任的發布者”。

我如何使第二個預設安裝到「受信任的發布者」?

如果可以的話。

答案1

我用 powershell 做了一個簡單的函數:

$in_cert = "C:\Users\Marian\Desktop\Pfx Certificate.pfx";
$password = Read-Host -AsSecureString;

# Read the pfx certificate data:
$pfx = (Get-PfxData -FilePath $in_cert -Password $password -ErrorAction Stop);

# Get the root and publisher certificate:
$root = $pfx.OtherCertificates[0];
$publisher = $pfx.EndEntityCertificates[0];

# Add the root:
$rootStore = Get-Item "Cert:\CurrentUser\Root";
$rootStore.Open('ReadWrite');
$rootStore.add($root);
$rootStore.close();

# Add the publisher:
$rootStore = Get-Item "Cert:\CurrentUser\TrustedPublisher";
$rootStore.Open('ReadWrite');
$rootStore.add($publisher);
$rootStore.close();

Pause;

若要跳過“根警告”,請使用“Cert:\LocalMachine”和“以管理員身份執行”。

相關內容