Convert PFX to Java Trust Store with password

Hi Guys,

I am after some assistance. SSL Certificates is not my strong point.

Basically I have been passed a PFX certificate and I need to create a Java Trust Store file with a trust store password. I have been searching the net a struggling to find a good answer on this. (or I am just not searching for the correct terms)

I am on Windows 7 machine.

Regards,

Nigel
Nigel_TaylorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave HoweSoftware and Hardware EngineerCommented:
you can do this with the java keytool - first, get the cert name with the keytool:

keytool -v -list -storetype pkcs12 -keystore <pfx file name>

Open in new window


then, input that to keytool and output to jks:

keytool -importkeystore 
-srckeystore <pfx file name> -srcstoretype pkcs12 -srcalias <cert name from above>
 -destkeystore <jks file name> -deststoretype jks -deststorepass <new jks p/w> -destalias <same as cert name>

Open in new window


(all one command, should prompt for pfx password)

much easier is to use this gui tool though - https://code.google.com/p/keytool-iui/

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Nigel_TaylorAuthor Commented:
Perfect, thank you.
Nigel_TaylorAuthor Commented:
Hi Dave,

Do you know how to import this certificate then into the lib\security\cacerts file?

Sorry this is an area of unfamiliarity for me.

Regards,

Nigel
Dave HoweSoftware and Hardware EngineerCommented:
Well, you don't want to import the entire keypair, just the cert - but the procedure is pretty much the same. if you use the gui keytool, then export > keystore's entry > trusted certificate, pick the pfx file (pkcs#12) and specify a pem file to store it into. then similarly, import > keystore's entry > trusted certificate > root ca certificate. default password for the cacerts is "changeit" (no, not a joke!)

for the cli keytool, you would use:
keytool -export -keystore <pfx file name> -storetype pkcs12 -alias <cert name from before> -file tmp.pem

Open in new window


then to get it into cacerts:
keytool -import -keystore <cacerts keystore name>  -alias <cert name from before> -file tmp.pem

Open in new window


doing this is pretty unusual though. normally, you have a signed keypair AND a ca cert you want to import that signed that keypair.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SSL / HTTPS

From novice to tech pro — start learning today.