Wednesday, 11 September 2024

Importing private key from existing PFX server certificate to Java key Store (JKS) file

 export CLASSPATH=/u01/app/jdk/lib/tools.jar:/u01/app/Oracle/Middleware/Oracle_Home/wlserver/server/lib/weblogic.jar


openssl pkcs12 -in mycertficate.pfx -out KEYSTORE.pem -nodes


get the private key and the certficate into pem a files 


where: 

Certificate.pem contents between below:

-----BEGIN RSA PRIVATE KEY-----

-----END RSA PRIVATE KEY-----


Privatekey.pem contents between below

-----BEGIN CERTIFICATE-----

-----END CERTIFICATE-----

Make sure you have both pfx and private key files with password



/u01/app/jdk/bin/keytool -import -trustcacerts -file Certificate.pem -alias mycertficate -keystore truststore.jks -storepass changeit -keypass changeit


java utils.ImportPrivateKey -keystore keystore.jks -storepass changeit -storetype JKS -keypass changeit -alias mycertficate -certfile Certificate.pem -keyfile Privatekey.pem -keyfilepass C0mm0NC3rt##2024


Now you should have both truststore.jks and keystore.jks


No comments:

Post a Comment

Number of Visitors