SSL Socket between .Net and Java with client authentication

Heetreall

New Member
I am trying to create an SSL Socket Server/Client between .NET and Java. In this case, my SSL Socket Server will run in .net and the client runs in Java under Linux. My problem is that the connection fails during the handshaking, specifically when the server request a certificate from the client, the client is unable to send something back and the connection fails.In .net I am using sslStream to establish the connection and on Java I am using the standard SSLSocket. Some code snippets are below, but this is what I have so far:On the server side (Windows), I have a private certificate in the Personal/Certificates folders under MMC. I have a public certificate from the client in the Trusted People/Certificates. Both certificates were issued by the same CA. The certificate chain for both certificates have multiple levels, but it is the same for both. The root level certificate in the chain is also installed in the trusted Certification Authorities/Certificates folder.On the client side (Linux), I have a keystore that contains the private certificate that matches the public certificate installed at the server. I have a trust store that contains the public certificate from the server, matching the server's private one.On the server side (.net) I am using a Socket that does an asynchronous read and then it gets wrapped into an SSLStream, the code snippet is like this:\[code\]NetworkStream ns = new NetworkStream(socket, false);SslStream ssl = new SslStream(ns, true);ssl.AuthenticateAsServer(serverCertificate, true, SslProtocols.Default, true);\[/code\]The client code is pretty much standard code:\[code\]SSLSocketFactory factory = (SSLSocketFactory) SSLSocketFactory.getDefault();InetAddress addr = InetAddress.getByName(servername);SSLSocket socket = (SSLSocket) factory.createSocket(addr,port);socket.setUseClientMode(true);socket.setNeedClientAuth(true);socket.setWantClientAuth(true);socket.startHandshake();os = new DataOutputStream(socket.getOutputStream());is = new DataInputStream(socket.getInputStream());byte[] outBuf = new byte[50];os.write("SEND SOMETHING".getBytes("UTF-8"));is.read(outBuf);\[/code\]In java I have set the proper varialbes to point to the trust and key store with their password.Now, following the standard SSL Handshake, this is what happens:
  • ClientHello
  • ServerHello
  • Server sends public certificate
  • Client matches the public certificate with the one on the trust store
  • Server sends the Certificate request
  • With the certificate request the server sends a list of valid CAs, on this list only the my root CA is sent (among a long list of other well known CAs.).
  • Client certificate is null.
  • Server receives a null certificate from the client, thus closes the connection.
And that is it, the client won't send a valid certificate back to the server. I have some questions on this:Has anybody experienced something like this? Regarding that list of CAs sent by the server (Windows), How does .net determine what to send to the client? Is there a way to modify that list? Do I need to send the all the authorities in the chain used to sign my certificate in that list of CAs? or is the Root one enough?Am I missing something on either side of my code?Any help will be greatly appreciated it.In
 
Top