Showing posts with label keytool. Show all posts
Showing posts with label keytool. Show all posts

Wednesday, 19 September 2012

Convert your pfx keystore to jks keystore

Many times we need to convert our PKCS12 keystore/digital signature/digital id file to JKS files.

There are various many ways of doing it . Most blogs talk about how OpenSSL would help you do it and other go on about new tools.But its all within java keytool's capabilities.

Its actually as simple as what I quote below.

Goto your <JAVA_HOME>/jre/bin


keytool -importkeystore -srckeystore MyPfx.pfx -srcstoretype pkcs12 -srcstorepass mysrcpassword  -destkeystore exportfrompfx.jks -deststoretype jks -deststorepass mydestpassword


This process will create a new jks file and call it exportfrompfx.jks

All the certificates with their aliases will be exported from MyPfx.pfx to exportfrompfx.jks

Use the following command then to verify your new keystore:

keytool -list -storetype jks -keystore exportfrompfx.jks -v


To selectively add each certificate use its alias.

Get the alias using the above mentioned list command

keytool -list -storetype jks -keystore exportfrompfx.jks -v


Use keytool to import that alias into your JKS keystore

keytool -importkeystore -srckeystore MyPfx.pfx -srcstoretype pkcs12 -srcstorepass mysrcpassword -srcalias alias -destkeystore exportfrompfx.jks -deststoretype jks -deststorepass mydestpassword -destalias destalias