Java Client/Server SSL Socket Chat -
Ok guys, so I created a Java chat using TCP client / server socket. I am making the server, and then I connect customers to the server so that they can communicate with each other through the server! Code: Server:
Public ServerAct () Exception {ServerSocket soc = New ServerSet (5217); While (true) {socket CSOC = society.exe (); // and then code to handle the messages, we do not need it}}
and the customer:
server soft = new socket (" 127.0.0.1 ", 5217); Thread t = new thread (this); T.start (); // I have omitted many parts of the code, but you know, I focus on the part of the problem connection!
So, I want to use SSL protection (so I see changes in Wirehaar). I have used OpenSSL (this is necessary for my accessory) to create Root CA and Device Certificate. I put files on Netbeans in SRT folder and copied the code to two new sections, SSL servers and SSLClient, and Ssl part! Therefore:
public SSL server (exception) {SSLContext sslContext = ???? Want to add / / file anyway here? SSLServerSocketFactory factory = (SSLServerSocketFactory) slContext.getServerSocketFactory (); SSLServerSocket sslserversocket = (SSLServerSocket) factory.createServerSocket (1234); While (true) {SSLSocket sslsocket = (SSLSocket) sslserversocket.accept (); }}
This is the case for the customer. So I'm stuck on a bit SSLContext part! I read many threads here, but still .. Is SSLContext right part of the bottom? And how do I use the certificate in SSLContext? EDIT: Maybe it will work? :
Main Store KS = Keystore.Just instance ("JSC"); Ks.load (new file inputstream ("Keystore"), "Keystore Password" .tokeray ()); KeyManagerFactory kmf = KeyManagerFactory.getInstance ("X509"); Km FIT (KS, "Keystore Password". Cochrane ()); TrustManagerFactory tmf = TrustManagerFactory.getInstance ("X509"); Tmf.init (KS); SSLContext sc = SSLContext.getInstance ("TLS"); Trustmanager [] Trust Manager = tmf.getTrustManagers (); Sc.init (km F.JetKey Manager (), Trust Manager, Faucet); SSLServerSocketFactory SSF = sc.getServerSocketFactory (); SSLServerSocket s = (SSLServerSocket) ssf.createServerSocket (serverport); SSLSocket C = (SSLSocket) s.accept ();
Anyway, I found some links that helped me! If you are interested, then
Comments
Post a Comment