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.
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.