sockets - Issue in executing SSL TLS client server Java programs -


i have started studying ssl tls in java , written simple client , server programs. run server program first, followed client program. on execution, client program gives following exception stack trace :-

exception in thread "main" javax.net.ssl.sslhandshakeexception: no cipher suites in common @ sun.security.ssl.alerts.getsslexception(unknown source) @ sun.security.ssl.sslsocketimpl.fatal(unknown source) @ sun.security.ssl.handshaker.fatalse(unknown source) @ sun.security.ssl.handshaker.fatalse(unknown source) @ sun.security.ssl.serverhandshaker.chooseciphersuite(unknown source) @ sun.security.ssl.serverhandshaker.clienthello(unknown source) @ sun.security.ssl.serverhandshaker.processmessage(unknown source) @ sun.security.ssl.handshaker.processloop(unknown source) @ sun.security.ssl.handshaker.process_record(unknown source) @ sun.security.ssl.sslsocketimpl.readrecord(unknown source) @ sun.security.ssl.sslsocketimpl.performinitialhandshake(unknown source) @ sun.security.ssl.sslsocketimpl.readdatarecord(unknown source) @ sun.security.ssl.appinputstream.read(unknown source) @ sun.nio.cs.streamdecoder.readbytes(unknown source) @ sun.nio.cs.streamdecoder.implread(unknown source) @ sun.nio.cs.streamdecoder.read(unknown source) @ java.io.inputstreamreader.read(unknown source) @ java.io.bufferedreader.fill(unknown source) @ java.io.bufferedreader.readline(unknown source) @ java.io.bufferedreader.readline(unknown source) @ sslserver.main(sslserver.java:19) 

please let me know solution problem. server , client programs follows :-

import java.io.bufferedreader; import java.io.inputstreamreader;  import javax.net.ssl.sslserversocket; import javax.net.ssl.sslserversocketfactory; import javax.net.ssl.sslsocket;  public class sslserver {    private static final int port = 8080;    public static void main(string[] args) throws exception {      sslserversocketfactory ssf = (sslserversocketfactory) sslserversocketfactory.getdefault();     sslserversocket ss = (sslserversocket)ssf.createserversocket(port);     sslsocket s = (sslsocket)ss.accept();     bufferedreader in = new bufferedreader(new inputstreamreader(s.getinputstream()));     string line = null;     while (((line = in.readline()) != null)) {       system.out.println(line);     }     in.close();     s.close();   } }    import java.io.outputstream;  import javax.net.ssl.sslsocket; import javax.net.ssl.sslsocketfactory;  public class sslclient {    private static final string host = "localhost";    private static final int port = 8080;    public static void main(string[] args) throws exception {     sslsocketfactory sf = (sslsocketfactory) sslsocketfactory.getdefault();     sslsocket s = (sslsocket)sf.createsocket(host, port);     outputstream out = s.getoutputstream();     out.write("\nconnection established.\n\n".getbytes());     out.flush();     int thecharacter = 0;     thecharacter = 5;     while (thecharacter != '~') // '~' escape character exit     {       out.write(thecharacter);       out.flush();       thecharacter = '~';     }      out.close();     s.close();   } } 

let client , server agree on common cipher. add below code both server , client.

string[] enableciphersuite = {"ssl_dh_anon_with_rc4_128_md5"}; s.setenabledciphersuites(enableciphersuite);


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -