Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export P7b file with all the certificate chain into CER file

I have p7b file provided by Thwate.When I am trying to export the certificate in the cer file using the below command, the certificate chain is not included.
Please suggest how to do the same. This CER is required for the importing into the weblogic key store.

openssl pkcs7 -print_certs -in certificate.p7b -out certificate.cer 
like image 998
Kunal Jha Avatar asked Jun 02 '11 07:06

Kunal Jha


People also ask

What is a P7B bundle?

p7b, *. p7s files contain one or more X. 509 digital certificate files that use base64 (ASCII) encoding. You get one of those in a zip file downloaded from your user account or receive such file from the Certificate Authority. You may also encounter *.


2 Answers

-print_certs is the option you want to use to list all of the certificates in the p7b file, you may need to specify the format of the p7b file you are reading.

You can then redirect the output to a new file to build the concatenated list of certificates.

Open the file in a text editor, you will either see Base64 (PEM) or binary data (DER).

openssl pkcs7 -inform DER -outform PEM -in certificate.p7b -print_certs > certificate_bundle.cer 

http://www.openssl.org/docs/apps/pkcs7.html

like image 101
bcarroll Avatar answered Sep 28 '22 11:09

bcarroll


The selected answer didn't work for me, but it's close. I found a tutorial that worked for me and the certificate I obtained from StartCom.

  1. Open the .p7b in a text editor.
  2. Change the leader and trailer so the file looks similar to this:

    -----BEGIN PKCS7----- [... certificate content here ...] -----END PKCS7----- 

For example, my StartCom certificate began with:

    -----BEGIN CERTIFICATE-----  

and ended with:

    -----END CERTIFICATE-----  
  1. Save and close the .p7b.
  2. Run the following OpenSSL command (works on Ubuntu 14.04.4, as of this writing):

    openssl pkcs7 -print_certs –in pkcs7.p7b -out pem.cer 

The output is a .cer with the certificate chain.

Reference: http://www.freetutorialssubmit.com/extract-certificates-from-P7B/2206

like image 44
fundatillus Avatar answered Sep 28 '22 13:09

fundatillus