
我使用 inetmgr 創建了一個 pfx 文件,其中包含證書的公鑰和私鑰。現在我嘗試從命令提示字元將 pfx 安裝到另一台機器上
certutil -p <password> -importpfx root <path_to_pfxfile>
不幸的是,這只是導入公鑰。如果我使用 certmgr 管理單元,我可以匯入兩個金鑰,但我需要能夠自動執行此操作。有人可以幫忙嗎?
答案1
PowerShell指令Import-PfxCertificate
可能會執行您想要的動作。 。
my.pfx
這會將文件中儲存的憑證和金鑰匯入到Trusted Root Certificate Authorities
本機電腦的憑證儲存中。
Import-PfxCertificate –FilePath C:\mypfx.pfx cert:\localMachine\Root -Password $password
您可能需要進行一些實驗才能找到用於感興趣的憑證儲存的名稱。我透過從 UI 複製相關儲存中的憑證指紋、刪除空格然後運行來完成此操作
ls|where {$_.Thumbprint -eq "<thumprint value here, with spaces removed>"}
這給了我這個作為輸出的一部分。
Directory: Microsoft.PowerShell.Security\Certificate::LocalMachine\Root
答案2
certutil 不匯入私鑰。您必須使用其他工具,例如 pk12util。
這個問題已經有了答案。在提問之前,請嘗試找到問題的解決方案。
看這個答案:https://serverfault.com/questions/647658/how-to-add-an-existing-key-to-the-certutil-key-database