Skip to content

Instantly share code, notes, and snippets.

@jmervine
Created November 17, 2014 21:57
Show Gist options
  • Star 34 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save jmervine/e4c9af3adb14b78856cc to your computer and use it in GitHub Desktop.
Save jmervine/e4c9af3adb14b78856cc to your computer and use it in GitHub Desktop.
openssl: convert cert from p7b to crt (or cer)
openssl pkcs7 -print_certs -in old.p7b -out new.crt
# openssl pkcs7 -print_certs -in old.p7b -out new.cer
@voquanghoa
Copy link

It saved my life. Thanks a lot

@vladkras
Copy link

mine too

@ozarembo
Copy link

thank you!!!!

@salvakexx
Copy link

this example also works for the files *.pkcs7 !
Thanks, jmervine!

@mcelhennyi
Copy link

I got an error, saying
unable to load PKCS7 object
so I did
openssl pkcs7 -inform der -in a.p7b -out a.cer
and this helped me.

@zhisme
Copy link

zhisme commented Mar 23, 2018

openssl pkcs7 -inform der -in a.p7b -out out.cer
return 0 exit code, but didn't work for further request.
So I did the following:
1 - openssl pkcs7 -print_certs -inform der -in a.p7c -out out.cer
2 - curl -E out.cer --key some_client_for_auth.key -X GET http://example.com

And then I get success response(200).

@leighhalliday
Copy link

I love you!!!!!! <3

@ocafebabe
Copy link

Thanks!

@Feriman22
Copy link

Thanks!

@Nenodema
Copy link

Nenodema commented May 3, 2021

Thanks!

@mrazekl
Copy link

mrazekl commented Nov 24, 2021

thank you

@parools
Copy link

parools commented Aug 31, 2022

Saved my life too !

@realtebo
Copy link

Thanks, but how to output to file ONLY the certificate?

I got some trailing lines in my case

subject=C = US, O = DigiCert Inc, OU = www.digicert.com, CN = DigiCert Global Root G2

issuer=C = US, O = DigiCert Inc, OU = www.digicert.com, CN = DigiCert Global Root G2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment