I get external .pem files that need to be converted to .p12 files - I add a username and password in the process. (I need to do this to utilize a thir
.pem
.p12
In Java, use Bouncycastle but be warned, learning curve is steep and documentation scarce. I strongly recommend you look at the examples which are available as part of the source distribution
Start with the PemReader.