Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a p12 file which apparently contains the server certificate. I need to extract the x509 server certificate from the p12 file so that I can add it to my java trust store, the problem is that I'm not quite sure how to do this.

share|improve this question

Java's keystore management tool:

keytool -keystore server.p12 -storetype pkcs12 -list

keytool -keystore server.p12 -storetype pkcs12 -exportcert -alias 1 -file server.crt

The output file will contain the X.509 certificate in DER format – but not the private key.


openssl pkcs12 -in server.p12 -out server.pem -nodes

The output file will contain both the X.509 certificate and the associated private key, both in PEM (base64) format.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.