Convert from P7B to PEM via OpenSSL
Solution 1:
Try this:
$ openssl pkcs7 -inform der -in a.p7b -out a.cer
If it doesn't work, brings to a Windows machine and export follow this guide.
Solution 2:
So to combine the above answers, the command is:
openssl pkcs7 -in cert.p7b -inform DER -print_certs -out cert.pem
Verified to be working on Windows, using OpenSSL-Win64
/Thanks Bogdan for spotting the error
Solution 3:
I followed this guide that instructs you to change the header/footer lines from
-----BEGIN PKCS #7 SIGNED DATA-----
[data]
-----END PKCS #7 SIGNED DATA-----
to
-----BEGIN CERTIFICATE-----
[data]
-----END CERTIFICATE-----
Then run the command openssl pkcs7 -in foo.modified.crt -print_certs -out foo.certs
(where foo.modified.crt
is the file that you saved the modified version into). This gave me the same results as running through a Windows certificate export as suggested in other answers.
Solution 4:
As far as I know, the following should convert a pkcs7 cert to a pem
openssl pkcs7 -in certificate_file.p7b -print_certs -out cert.pem
Solution 5:
quick solution in my case (a lot of files with missing header/footer) :
base64 -d $FILE | openssl pkcs7 -inform DER -print_certs