Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load multiple certificates into PKCS12 with openssl

Tags:

I am trying to load multiple certificates using openssl into the PKCS12 format. The command is as follows:

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 

Having parsed the generated PKCS12 file, only the last certificate has been included into the file:

openssl pkcs12 -in test.p12 -info -nodes 

I also tried to import them separately into the pkcs12 file while in all the attempts, only the last certificate was remained in the file.

Any idea where is the problem to solve it?

like image 629
Mohammad Khodaei Avatar asked Oct 31 '13 11:10

Mohammad Khodaei


1 Answers

First, make sure all your certificates are in PEM format. Then, make a SINGLE file called "certs.pem" containing the rest of the certificates (cert2.arm, cert3.arm, and RootCert.pem).

Then use the command like this:

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

The openssl pkcs12 documentation explains the different options.

like image 182
gtrig Avatar answered Sep 19 '22 20:09

gtrig