tags:

views:

1124

answers:

2

I want to take a public key .cer file generated from java keytool command like this:

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

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

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

except I want to do the import programmatically, using JSSE.

Stack Overlords, work your magic! Thanks!

A: 

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

Unzip the tools.jar in a folder and use the following command to decompile all classes inside that 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 class sun.security.tools.KeyTool

Reginaldo
A: 

Look at the KeyStore class in Java. Here is a class which might give you some hints. You might require the free BouncyCastle crypto provider to operate all of its function

kd304