For Programmers: Free Programming Magazines  


Home > Archive > Java Security > January 2006 > How to store the generated Key using KeyStore into the File









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How to store the generated Key using KeyStore into the File
ganesh.gulecha@gmail.com

2006-01-30, 3:58 am

Hi,
I have the code for reading the available key from the File using
the KeyStore. But, i have tried my best to store the generated key into
the File and i m not able to. Can some one help in these.

Thanks in Advance!

Regards,
Ganesh.G.

Lion-O

2006-01-31, 7:08 pm

> I have the code for reading the available key from the File using the
> KeyStore. But, i have tried my best to store the generated key into the File
> and i m not able to. Can some one help in these.


Actually the only thing you'd need to do is taking a closer look at the
examples in the JDK documentation. The specification for the KeyStore class
also list an example how to load/store keys, check
http://java.sun.com/j2se/1.5.0/docs.../KeyStore.html.

Another read which has helped me a lot is
http://java.sun.com/j2se/1.5.0/docs...ryptoSpec.html.

But summing up; the only thing you need is to add the key to the keystore using
the "KeyStore.setEntry" method. Once you've done that you can save it using an
FileOutputStream. From the top of my mind:

FileOutputStream fos = new FileOutputStream("name_of_keystore");
KeyStore.store(fos, "keystorepassword");
fos.close();


Now, do check this carefully. I'm not 100% positive that I got it all right,
but am pretty sure on the overall commands.


--
Groetjes, Peter

..\\ PGP/GPG key: http://www.catslair.org/pubkey.asc
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com