1

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
user207421
  • 305,947
  • 44
  • 307
  • 483
user1649517
  • 19
  • 2
  • 5
  • 1
    server.setEnabledCipherSuites(server.getEnabledCipherSuites()) does precisely nothing. I strongly suggest you don't mess with SSL parameters like this if you don't know what you're doing. – user207421 Sep 05 '12 at 23:29

1 Answers1

2

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

Community
  • 1
  • 1
Bruno
  • 119,590
  • 31
  • 270
  • 376
  • Thanks, so i need to load it to window's truststore before do something? – user1649517 Sep 06 '12 at 01:26
  • Not only, you need to create (or obtain) a certificate (with its private key) for your server, put it in a keystore and use this as a trust store. You then need to export the certificate itself (without the private key) and import it in the Windows trusted certificates store indeed. – Bruno Sep 06 '12 at 01:29