By default, Java does not support PEM format, but it does support JKS and PKCS#12. This article will demonstrate how to use OpenSSL to combine an existing PEM file and its private key into a single PKCS#12 or.p12 file.
Let's convert cert.pem and private key pem to p12 file using following command
openssl pkcs12 -export -out cert.p12 -in cert.pem -inkey key.pem -passout pass: changeit
If you want to convert PFX to p12 just try to change the file extension from .pfx to .p12 , both of them are PKCS#12 files. If it did not help try the following :
keytool -importkeystore -destkeystore new.p12 -deststoretype pkcs12 -srckeystore original.pfx