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
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.
Change the leader and trailer so the file looks similar to this:
For example, my StartCom certificate began with:
and ended with:
Run the following OpenSSL command (works on Ubuntu 14.04.4, as of this writing):
The output is a .cer with the certificate chain.
Reference: http://www.freetutorialssubmit.com/extract-certificates-from-P7B/2206
I had similar problem extracting certificates from a file. This might not be the most best way to do it but it worked for me.
The only problem is that any additional certificates in resulted file will not be recognized, as tools don't expect more than one certificate per PEM/DER encoded file. Even openssl itself. Try
and see for yourself.
-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).
http://www.openssl.org/docs/apps/pkcs7.html
If you add -chain to your command line, it will export any chained certificates.
http://www.openssl.org/docs/apps/pkcs12.html