Thursday, June 25, 2015

Genereate .p7b file from multiple .cer files

A p7b file can contain many CA certificates. This can for example be the case when creating a bundle of CA certificates. As was the case for me.

In a project I'm working on we want to bundle all the trused CA certificates in one file. The file for this purpose was p7b.

We used openssl to do it.

The first thing that needs to be done is to convert the .cer files to PEM.

openssl x509 -in myCA1.cer -inform DER -outform pem -out myCA1.pem
openssl x509 -in myCA2.cer -inform DER -outform pem -out myCA2.pem

And then we bundle the PEM files

openssl crl2pkcs7 -nocrl -certfile myCA1.pem -certfile myCA1.pem -outform PEM -out bundle.p7b

To add another PEM fil just add another -certfile argument.

No comments:

Post a Comment