For Programmers: Free Programming Magazines  


Home > Archive > Java Security > November 2005 > Kava API for Keytool









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 Kava API for Keytool
tremalnaik@gmail.com

2005-11-03, 3:58 am

Hello,
I'm developing a swing application to produce certificates easily, for
users who don't like typing commands into the console.

I'm trying to write some java code which let me do something equivalent
to the following command:

C:\Documents and Settings\tremalnaik>keytool -genkey -alias
server.alias.com -keyalg RSA -keypass pass1 -storepass pass2 -keystore
keystore.jks -validity num_days

I searched the JAVA cryptographic API but they gave me the impression
they don't let you create a keystore, but only load it from a file.

Alternatively, I may use the Runtime.exec(), but I don't like very much
this solution.

Can you help me?

TREMALNAIK

Tommy Grändefors

2005-11-03, 7:02 pm

Hi,

Don't use Runtime.exec().
You can create a new key store from the method
'KeyStore.load(InputStream stream, char[] password)' by using null as
input parameters (please read the javadoc for that method). When you
have finished working with your key store, then you have to use method
'KeyStore.store(OutputStream stream, char[] password)' to save it on
disk.

Here's how to create a new jks key store:

KeyStore ks =3D KeyStore.getInstance("JKS");
ks.load(null, null);

Good luck with your application.

Regards,
Tommy Gr=E4ndefors
www.pheox.com

tremalnaik@gmail.com wrote:
> Hello,
> I'm developing a swing application to produce certificates easily, for
> users who don't like typing commands into the console.
>
> I'm trying to write some java code which let me do something equivalent
> to the following command:
>
> C:\Documents and Settings\tremalnaik>keytool -genkey -alias
> server.alias.com -keyalg RSA -keypass pass1 -storepass pass2 -keystore
> keystore.jks -validity num_days
>
> I searched the JAVA cryptographic API but they gave me the impression
> they don't let you create a keystore, but only load it from a file.
>
> Alternatively, I may use the Runtime.exec(), but I don't like very much
> this solution.
>=20
> Can you help me?
>=20
> TREMALNAIK


Sponsored Links







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

Copyright 2008 codecomments.com