【问题标题】:Load multiple certificates into PKCS12 with openssl使用 openssl 将多个证书加载到 PKCS12
【发布时间】:2013-11-11 08:47:33
【问题描述】:

我正在尝试使用 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 文件,而在所有尝试中,文件中只保留了最后一个证书。

知道哪里有问题要解决吗?

【问题讨论】:

    标签: openssl x509certificate pkcs#12


    【解决方案1】:

    首先,确保您的所有证书都是 PEM 格式。然后,制作一个名为“certs.pem”的单个文件,其中包含其余证书(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 文档解释了不同的选项。

    【讨论】:

    • 有没有办法自动完成?手动将证书添加到单个文件中似乎不切实际(当涉及到从 PKCS12 文件中添加/删除证书时)。
    • 您可以在用于创建 pkcs12 文件的同一命令行上将各个文件连接成一个组合文件。例如在 Windows 中,type cert2.arm cert3.arm RootCert.pem > combined.pem & openssl pkcs12 ...。在 Linux/Unix 中,你可以这样做 cat cert2.arm cert3.arm RootCert.pem > combined.pem; openssl pkcs12 ...
    • 有什么方法可以使用openssl 将证书添加 到现有的pkcs12 文件中?我知道你可以从头开始组装一个,但是添加一个呢?
    • @ChristopherSchultz 我也在为此苦苦挣扎。我相信只有 Java 的 keytool 才能正确处理这个问题。
    猜你喜欢
    • 2013-04-28
    • 2017-10-27
    • 1970-01-01
    • 2017-07-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-21
    • 2012-04-05
    • 1970-01-01
    相关资源
    最近更新 更多