'How to import a certificate with private key to JRE cacerts

My goal is my spring boot app to be able to consume https api. I have a pfx paired with the private key and i want to import it to cacerts. keytool -import -alias cert -keystore "%JAVA_HOME%"/lib/security/cacerts -file myfile I get that this isn't a input not an X.509 certificate when i convert it to crt or pem or der doesn't work, after the conversion its like the private key isn't there, even if the pem when I open it with text I see the private key.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source