dcsimg
Pl. list out the steps to make the EchoServer.java EchoClient.java attached work with Verisign Trial Server ID?
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Velidanda_Srinivas
Posted On:   Monday, December 24, 2001 03:06 AM

I have followed the following steps. 1. Got the Verisign Trial Server ID using CSR created from Keytool. 2. Exported it to DER format using IE5 3. Imported the public key to keystore to use it as trustStore for the server. Installed the certificate into the browser, and added it to cacerts file. C:jsse1.0.2samplessrc>java -Djavax.net.ssl.keyStore=.keystore -Djav ax.net.ssl.keyStorePassword=passphrase -Djavax.net.ssl.trustStore=s5emptrust EchoServer C:jsse1.0.2samplessrc>java -Djavax.net.ssl.trustStore=s5emptrust EchoServer getting untrusted server cert chain at client side.. Code Follows.. EchoServer.java    More>>

I have followed the following steps.



1. Got the Verisign Trial Server ID using CSR created from Keytool.



2. Exported it to DER format using IE5



3. Imported the public key to keystore to use it as trustStore for the server.



Installed the certificate into the browser, and added it to cacerts file.



C:jsse1.0.2samplessrc>java -Djavax.net.ssl.keyStore=.keystore -Djav
ax.net.ssl.keyStorePassword=passphrase -Djavax.net.ssl.trustStore=s5emptrust EchoServer



C:jsse1.0.2samplessrc>java -Djavax.net.ssl.trustStore=s5emptrust EchoServer



getting untrusted server cert chain at client side..

Code Follows..


EchoServer.java


import java.io.InputStream;

import java.io.InputStreamReader;

import java.io.BufferedReader;

import java.io.IOException;

import java.security.*;


import javax.net.ssl.SSLSocket;

import javax.net.ssl.SSLServerSocket;

import javax.net.ssl.SSLServerSocketFactory;


public class EchoServer

{

public static void main(String [] arstring)

{

try

{

Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

}catch(Exception eee)

{

System.out.println("Exception at addProvider ...........");

eee.printStackTrace();

}
try

{

SSLServerSocketFactory sslserversocketfactory =
(SSLServerSocketFactory)SSLServerSocketFactory.getDefault();

SSLServerSocket sslserversocket =
(SSLServerSocket)sslserversocketfactory.createServerSocket(9999);

while(true)

{

SSLSocket sslsocket = (SSLSocket)sslserversocket.accept();


InputStream inputstream = sslsocket.getInputStream();

InputStreamReader inputstreamreader = new InputStreamReader(inputstream);

BufferedReader bufferedreader = new BufferedReader(inputstreamreader);


String string = null;

while ((string = bufferedreader.readLine()) != null)

{

System.out.println(string);

System.out.flush();

}

}

}

catch (Exception exception)

{

exception.printStackTrace();

}

}

}



EchoClient.java


import java.io.InputStream;

import java.io.OutputStream;

import java.io.InputStreamReader;

import java.io.OutputStreamWriter;

import java.io.BufferedReader;

import java.io.BufferedWriter;

import java.io.IOException;

import java.security.*;


import javax.net.ssl.SSLSocket;

import javax.net.ssl.SSLSocketFactory;


public
class EchoClient

{

public
static
void
main(String [] arstring)

{

try

{

Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

}catch(Exception eee)

{

System.out.println("Exception at addProvider ...........");

eee.printStackTrace();

}

try

{

SSLSocketFactory sslsocketfactory = (SSLSocketFactory)SSLSocketFactory.getDefault();

SSLSocket sslsocket = (SSLSocket)sslsocketfactory.createSocket("192.168.1.6", 9999);


InputStream inputstream = System.in;

InputStreamReader inputstreamreader = new InputStreamReader(inputstream);

BufferedReader bufferedreader = new BufferedReader(inputstreamreader);


OutputStream outputstream = sslsocket.getOutputStream();

OutputStreamWriter outputstreamwriter = new OutputStreamWriter(outputstream);

BufferedWriter bufferedwriter = new BufferedWriter(outputstreamwriter);


String string = null;

while ((string = bufferedreader.readLine()) != null)

{

bufferedwriter.write(string + '
');

bufferedwriter.flush();

}

}

catch (Exception exception)

{

exception.printStackTrace();

}

}

}




Pl. send me the right sequence of steps, or the fix for the error.

Srinivas.

   <<Less
About | Sitemap | Contact