Import-PfxCertificate 未将证书保存在指定的系统存储位置

Import-PfxCertificate not saving certificate in designated System Store Location

我正在尝试通过 powershell 安装 mitmproxy.org 提供的证书,但 windows 没有将证书保存在正确的位置。

我尝试执行的命令 运行:

Get-ChildItem -Path c:\mitmproxy-ca-cert.p12 | Import-PfxCertificate -CertStoreLocation cert:\LocalMachine\Root 它没有将证书插入受信任的根证书颁发机构,而是将其放入中间证书颁发机构。

Get-ChildItem -Path c:\mitmproxy-ca-cert.p12 | Import-PfxCertificate -CertStoreLocation cert:\CurrentUser\Root 与第一个命令相同。

即使将工作位置设置为 PS Cert:\localmachine\Root> 也无法导入到 Root 位置。 Get-ChildItem -Path c:\mitmproxy-ca-cert.p12 | Import-PfxCertificate -CertStoreLocation .

没有错误,所有命令 运行 他们的过程。我 运行 他们拥有管理员权限。

然而,手动左键单击 mitmproxy-ca-cert.p12 确实会启动一个导入 GUI,该 GUI 成功地将其导入到根目录位置。为什么 powershell 不工作?

遵循 mitmproxy.org 自己的命令行安装指南没有用,因为它根本不起作用:

如何在 Windows 上安装(自动)

certutil.exe -importpfx Root mitmproxy-ca-cert.p12

C:\>certutil -importpfx Root mitmproxy-ca-cert.p12
Enter PFX password:
CertUtil: -importPFX command FAILED: 0x80092007 (-2146885625 CRYPT_E_SELF_SIGNED)
CertUtil: The specified certificate is self signed.

任何人都可以阐明这里发生了什么吗?谢谢。

我给你写个剧本,有不懂的告诉我

$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;

我也post编辑了我的post:My Post