This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Sockets and Internet Protocols and the fly likes JSSE Client authentication problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "JSSE Client authentication problem" Watch "JSSE Client authentication problem" New topic

JSSE Client authentication problem

leor amikam

Joined: Oct 22, 2009
Posts: 2

I am a total SSL newbie. I have to connect to a 3rd party app via a SSL/TCP connection (not https). They vendor provided example code that works under C#. I need to emulate the same connection method, but in Java. The C# code looks something like this:

client = new TcpClient(hostName, int.Parse(clientPort));
sslStream = new SslStream(client.GetStream(), ...);

So, I am provided with only three input parameters - host name, port, and a "server name". It appears that the .net runtime function, AuthenticateAsClient, lets you authenticate the connection with just the service name (not sure if that is the correct designation). There is no certificate of any kind on the client machine that is connection to the SSL server. Although I have found many SSL/Java examples on the web, I don't know what the construct/function calls would be in a Java environment to emulate the behavior of this AuthenticateAsClient function. Any help ig greately appreciated.

Here's some more detail. I looked at the JSSE tutorial.

OK, I looked at the tutorials, and am still missing some key bit of knowledge. Here is my example code:

SSLSocketFactory sslsocketfactory = (SSLSocketFactory)SSLSocketFactory.getDefault();
SSLSocket sslsocket = (SSLSocket)sslsocketfactory.createSocket("usatl-w-100624", 11000);
InputStream inputstream =;
InputStreamReader inputstreamreader = new InputStreamReader(inputstream);
BufferedReader in = new BufferedReader(inputstreamreader);
OutputStream outputstream = sslsocket.getOutputStream();
OutputStreamWriter ow = new OutputStreamWriter(outputstream);


On the call to startHandshake(), I get this error: PKIX path building failed: unable to find valid certification path to requested target

Of couse, this is expected, as I do not have a certificate in the java keystore. If I look at the JSSE examples, here:
The example looked relevant. However, it also is requesting a file path. My C# example does not access any file on the client. So, how do you do the equivalent in Java?


It is sorta covered in the JavaRanch Style Guide.
subject: JSSE Client authentication problem
Similar Threads
SSL Server and Client Communication
HTTP Post SSL certificates (Jakarta HTTP Commons)
regarding https connectivity No available certificate or key corresponds to the SSL ci
SSL enabled client code with client authentication