A certificate is never simple. You need to open openssl (the version of Cygwin runs on Windows) to convert the pfx / p12 file to a pem file, then you can create a certificate from pem. Finally, you can use the Java keytool program to convert the certificate to the JKS format (default for KeyStore).
Convert pfx to pem:
openssl pkcs12 -in whatever.pfx -out whatever.pem -clcerts -nokeys
Create an X509 certificate from the pem file:
openssl x509 -in whatever.pem -inform PEM -out whatever.crt -outform DER
Use Java keytool to create a JKS file from a certificate:
keytool -import -trustcacerts -keystore whatever.jks -storepass somepassword -noprompt -file whatever.crt -alias localhost
Note that -alias can be any unique name that you want to use for this certificate. The agreement is to use the URL of your website.
Now you can load the JKS file with the KeyStore instance into your code. Maybe it's easier to just change your Java code to use a PKCS12 instance?
source share