我可以在没有私钥的情况下将多个证书合并为一个吗?

Can I combine multiple certs into one without the private key?

我需要在许多设备中拥有最新的证书信任库,因此我希望能够将它们合并到一个证书中,然后我可以只推送那个文件。我只想捆绑许多 CA 的 public 密钥,但我不想添加私有文件,因为我想要一个我推送到我所有设备的证书。我在想这个功能被称为链但是 openssl 不会在没有私有文件的情况下接受命令。这可以做到吗?我已经尝试了几种不同的方法,并且在这里查看了很多线程,但我不知道自己在做什么。

编辑

我尝试使用的命令是:

openssl -export -pkcs12 -out output.pem -cafile intermediate.pem

编辑

我尝试了 "openssl crl2pkcs7 -certfile bundle.pem -out p7.pem" 但它产生了一个错误:

openssl crl2pkcs7 -certfile bundle.pem -out p7.pem
unable to load CRL
9460:error:0906D06C:PEM routines:PEM_read_bio:no start line:.\crypto\pem\pem_lib.c:701:Expecting: X509 CRL

我也试过:

openssl pkcs7 -in bundle.pem -out p7.pem
unable to load PKCS7 object
3676:error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag:.\crypto\asn1\tasn_dec.c:1201:
3676:error:0D06C03A:asn1 encoding routines:ASN1_D2I_EX_PRIMITIVE:nested asn1 error:.\crypto\asn1\tasn_dec.c:765:
3676:error:0D08303A:asn1 encoding routines:ASN1_TEMPLATE_NOEXP_D2I:nested asn1 error:.\crypto\asn1\tasn_dec.c:697:Field=type, Type=PKCS7
3676:error:0906700D:PEM routines:PEM_ASN1_read_bio:ASN1 lib:.\crypto\pem\pem_oth.c:83:

如果您已经有证书,您可以简单地连接它们:

cat cert1.pem cert2.pem > bundle.pem

但是,这实际上取决于每个信任库期望的格式。因此,例如,Public Key Cryptography Standards 描述了几种可用于分发证书、密钥等的标准。其中之一是 PKCS#7,它通常用于捆绑一组没有私钥的证书。您可能需要查看每个设备如何实现信任库,因为它们可能都需要不同的格式。