Getting this error: “javax.net.ssl.SSLHandshakeException: no cipher suites in common”

本小妞迷上赌 提交于 2019-12-23 01:46:16

问题


I have a client written in C# and server in JAVA. So, when I'm trying to connect I got error in server javax.net.ssl.SSLHandshakeException: no cipher suites in common and in C# "EOF or 0 bytes".

[C#]:

  TcpClient tc = new TcpClient(server, 1337); 


            using (sslStream = new SslStream(tc.GetStream())){ }

[JAVA]:

   SSLServerSocketFactory ssocketFactory = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
   SSLServerSocket server = (SSLServerSocket) ssocketFactory.createServerSocket(1337);
   server.setEnabledCipherSuites(server.getEnabledCipherSuites());

And JAVA launch properties:

-Djavax.net.ssl.trustStore=Certificatename -Djavax.net.ssl.trustStorePassword=thereisapw -Djava.protocol.handler.pkgs=com.sun.net.ssl.internal.www.protocol -Djavax.net.debug=ssl TCPServer

回答1:


The truststore defines how you're going to trust remote certificates that are presented to you. The keystore is for the certificates you have (and for which you have the private key). (More details about the difference here. The terminology about "keystore" can be confusing, since it can have two meanings).

Here, you're trying to run a server, but you haven't set up your own certificate. You need to import/create a certificate in a keystore and use it as a keystore.

If you don't specify a keystore, the server won't be able to find a cert/key. As a result, it won't be able to use any of the cipher suites enabled by default.


I'm not sure where you got this from, but you don't need it: -Djava.protocol.handler.pkgs=com.sun.net.ssl.internal.www.protocol



来源:https://stackoverflow.com/questions/12284756/getting-this-error-javax-net-ssl-sslhandshakeexception-no-cipher-suites-in-co

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!