views:

60

answers:

2

Hi,

I'm looking at coding up a very simple server using an ssl connection - but had two questions

How can i use the java keytool in windows to generate a certificate I can use for testing? Most tutorials i can see (for echoservers etc) suggest i run the following command, which doesnt appear to work in the command prompt (running win 7)?

keytool -keystore mySrvKeystore -keypasswd 123456 -genkey -keyalg RSA -alias mycert

Also considering ill be doing some basic AES and RSA based encryption - is there an advantage in using bouncy castle instead of the tools provided off the shelf in the JCE?

Many thanks,

+1  A: 

The -genkey option must come first.

If JCE supports the algorithms you want to use (and it does support AES and RSA), switching to BouncyCastle is extra hassle with no benefit. BouncyCastle would be a great choice if you need something like ECDH, or if you want to use its S/MIME or PGP libraries.

erickson
Hi, sprry i should have been more eplicit - when i say it 'doesnt work' i meant that windows command prompt doesnt recognize 'keytool' as a valid command.Im using the java / netbeans budle, could the above be because i dont have java EE edition?many thanks
oneAday
@oneAday. Provide a full path to a keytool executable, usually `C:\Program Files\jre6\bin\keytool.exe`, or if you use SDK in SDK's bin directory.
Alexander Pogrebnyak
Yes, provide the full path. The JDK and JDK tools aren't placed on the path during installation on Windows; `java` and `javaw` commands are included in the Windows system directory. You can either modify your `PATH` variable or specify a full path on the command line.
erickson
aha! of course, thank you :)
oneAday
+1  A: 

If you already have a private key in PEM or DER format and a signed certificate for it, you may use pkeytool to create keystore file from it ( basically import private key into pkcs file format ).

Alexander Pogrebnyak