SSLSocket and client public key issue

Hi All

I am writing a server that will use SSLSocket. I am new to this. I have created the server private key, public key, dummy client private key, public key. Now the problem is that to create a SSLSocket i am using the client public key which i created, but the problem is that in mycase all clients will have their own public - private key. So basically i have no clue as to how to integrate all those public keys in my program.

If anyone can give any pointers in this issue.

Thanks and Regards

Pankaj Tiwari

Here is a part of code that uses the keystore

Variables

private String SKEYSTORE="D:\\eclipsetest\\FDRTest\\certificates\\server\\client.public";

private String CKEYSTORE="D:\\eclipsetest\\FDRTest\\certificates\\client\\server.private";

privatechar[] KEYSTOREPW="123456".toCharArray();

these lines are from the init method that initialises the server socket

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

KeyStore serverkeystore = KeyStore.getInstance("JKS");

KeyStore clientkeystore=KeyStore.getInstance("JKS");

serverkeystore.load(new FileInputStream(SKEYSTORE), KEYSTOREPW);

clientkeystore.load(new FileInputStream(CKEYSTORE), KEYSTOREPW);

TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");

tmf.init(serverkeystore);

KeyManagerFactory kmf=KeyManagerFactory.getInstance("SunX509");

kmf.init(clientkeystore,"123456".toCharArray());

SSLContext sslc = SSLContext.getInstance("TLS");

sslc.init(kmf.getKeyManagers(), tmf.getTrustManagers(),null);

ServerSocketFactory ssf = sslc.getServerSocketFactory();

SSLServerSocket serverSocket =(SSLServerSocket)

ssf.createServerSocket(portnumber);

serverSocket.setNeedClientAuth(true);

[2360 byte] By [pkta] at [2007-11-27 3:12:40]
# 1

All the client public keys have to be in the server's truststore if they are self-signed. If they are signed by a CA then the CA's certificate needs to be in the server's truststore, or the CA's signer's cert, or ... etc recursively. The Java truststore already contains the certs of the major root CAs so if you use a proper one you don't have to do anything.

ejpa at 2007-7-12 8:15:10 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 2

Can u help me out with this..

I was able to run a servlet on tomcat with HTTPS. Now the confusion is that i am not sure what the keystore file actually contains, after doing some reading i come to know that it has public as well as private key, first of all is it correct.

Secondly, now my requirement is to write a server program that will use SSL and the public key and private key from different files ( most probably database).

In the program that was with tomcat, nowhere i specified any private key or public key, i just gave the truststore path. Just one line i.e System.setProperties.....

can anyone guide me how to proceed ahead. I want to use SSLSecureSocket and public key and private key from different files

pkta at 2007-7-12 8:15:10 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...