Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"SocketException: Unconnected sockets not implemented" with self-signed SSL certificate

Tags:

java

ssl

(I've asked the same question of the jmeter-user mailing list, but I wanted to try here as well - so at the least I can update this with the answer once I find it).

I'm having trouble using JMeter to test a Tomcat webapp using a self-signed SSL cert. JMeter throws a SocketException with message Unconnected sockets not implemented. According to JMeter's docs, the application is designed and written to accept any certificate, self-signed or CA signed or whatever.

Has anyone run into this specific exception before?

I've attempted to export this certificate from the server and import it into my local keystore (with keytool -import -alias tomcat -file ), but the result is the same.

I've also tried setting javax.net.debug=all as a JVM arg (the JSSE reference guide lists this as a debugging step); however, I don't see any debugging output anywhere - should I expect this somewhere other than standard out/error?

like image 768
matt b Avatar asked Sep 22 '08 18:09

matt b


2 Answers

Most javax.net.SocketFactory implementations define all createSocket() methods that have parameters as abstract. But have a createSocket() method without parameters that looks like this:

public Socket createSocket() throws IOException {
   throw new SocketException("Unconnected sockets not implemented");
}

So if you subclass the abstract javax.net.SocketFactory you will be force to override the methods with parameter, but it's easy to miss to override the createSocket() method without parameters. Thus the exception is thrown if your code calls createSocket(). Simply override the method and the be done. :)

like image 52
Flow Avatar answered Oct 04 '22 20:10

Flow


I had the same problem in my code (not related to JMeter).

My code uses a self-defined SocketFactory. What I found out is that the class com.sun.jndi.ldap.Connection calls some methods of the SocketFactory using Method.invoke(). One of the methods it tries to call is createSocket() - without parameters.

When I added such method to my factory all worked fine.

like image 41
Dikla Avatar answered Oct 04 '22 18:10

Dikla