How to programmatically import a .cer public key file into java repository using JSSE?

I want to take the .cer public key file generated from the java keytool command as follows:

"keytool -export -alias privatekey -file publickey.cer -keystore privateKeys.store"

and import it into a new, empty java repository like this:

"keytool -import -alias publiccert -file publickey.cer -keystore publicCerts.store"

except that I want to do import programmatically using JSSE.

Overlapping the stack, work with your magic! Thanks!

+6
java jsse
source share
2 answers

Take a look at the KeyStore class in Java. Here is a class that can give you some advice. You may need a free BouncyCastle cryptography provider to work its full function.

+2
source share

If you use jad to decompile the tools.jar that comes with the Sun JDK, you'll see exactly how it works.

Unzip tools.jar to a folder and use the following command to decompile all classes inside this jar.

  for i in $ (find. -name "* .class" | perl -ple 's / \. class $ // g');  do jad -p $ i.class> $ i.java;  done

The keytool source can be seen in the sun.security.tools.KeyTool class

0
source share

All Articles