2013-10-31 50 views
14

我試圖使用openssl將多個證書加載到PKCS12格式中。命令如下:使用openssl將多個證書加載到PKCS12中

openssl pkcs12 -export -in cert1.arm -inkey cert1_private_key.pem -certfile cert2.arm -certfile cert3.arm -certfile RootCert.pem -name "Test" -out test.p12 

已經解析生成的PKCS12文件中,只有最後一個證書已被列入到文件:

openssl pkcs12 -in test.p12 -info -nodes 

我也試圖分別將其導入到PKCS12文件,而在所有的嘗試中,只有最後一個證書保留在文件中。

任何想法解決它的問題在哪裏?

回答

17

首先,確保您的所有證書都是PEM格式。然後,創建一個名爲「certs.pem」的SINGLE文件,其中包含其餘證書(cert2.arm,cert3.arm和RootCert.pem)。

然後使用命令如下:

openssl pkcs12 -export -in cert1.arm -inkey cert1_private_key.pem -certfile certs.pem -name "Test" -out test.p12 

openssl pkcs12文檔解釋了不同的選擇。

+0

有沒有辦法自動執行它?手動將證書添加到單個文件似乎並不實際(當涉及到從PKCS12文件添加/刪除證書時)。 –

+3

您可以將單個文件連接到用於創建pkcs12文件的同一命令行中的組合文件。例如在Windows中,鍵入cert2.arm cert3.arm RootCert.pem> combined.pem&openssl pkcs12 ...'。在Linux/Unix中,您可以執行'cat cert2.arm cert3.arm RootCert.pem> combined.pem; openssl pkcs12 ...' – gtrig