-->

Getting this error: “javax.net.ssl.SSLHandshakeExc

2019-06-01 01:51发布

问题:

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



标签: java c# .net ssl jsse