Saturday, May 28, 2005

jsse tips

1. To add public key to keystore from certificat file (*.pem, *.der, *.cer) is as below:
keytool -import -alias myalias -file certfile -keypass passwd -keystore storename -storepass passwd

2. To start a java client with debug info is:
java -Djavax.net.debug=ssl -Djavax.net.ssl.KeyStore=storename -Djavax.net.ssl.trustStore=storename javaclient


3. Use the below java code that works with point #2 above.

SSLSocketFactory factory = (SSLSocketFactory)SSLSocketFactory.getDefault();
SSLSocket socket = (SSLSocket) factory.createSocket("localhost", 443).

rest of the code is standard to get output stream and use buffered reader.

4. an alternate approach is at javaworld article

No comments: