aspose file tools*
The moose likes Distributed Java and the fly likes SSLHandshakeException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "SSLHandshakeException" Watch "SSLHandshakeException" New topic
Author

SSLHandshakeException

Santh Narayanan
Greenhorn

Joined: Jul 01, 2002
Posts: 18
I am trying to test an example using RMI over SSL.

The example doesn't give me an error when I use LocateRegistry.createRegistry(<port> to start a registry in the application.
When I comment out the LocateRegistry and use the command line rmiregistry <port> I get this error when it tries to do Naming.bind(name, server);.




Thanks.
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

I think it's because you're setting the SecureRMISocketFactory as the RMISocketFactory - it's probably assuming that *all* socket communication is going to be using SSL. If you start the registry outside the server, it's not going to be using this SocketFactory, so when your server tries to register with the registry, it uses an SSL socket, but gets a "regular" socket response from the registry.

It's possible to use the "regular" registry, but still use a custom socket factory between your client and server - the Using a Custom Socket Factory guide on Sun's site shows how.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Santh Narayanan
Greenhorn

Joined: Jul 01, 2002
Posts: 18
That worked and also understood the concept.
I really appreciate your answer.

Thanks Nathan,
Santh Narayanan
Greenhorn

Joined: Jul 01, 2002
Posts: 18
I start my server with the following code, which works perfect,
it doesn't give an exception if I run the main method in this class.

If I try to run the client, i get the error.

one thing I have noted, the NotSerializableException does not
occur with the Registry.rebind invocation is that you invoke rebind on
a registry reference returned from LocateRegistry.createRegistry

I this situation I am using rmiregistry command.


Error:

HelloClient exception: error unmarshalling return; nested exception is:
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: com.sun.ne
t.ssl.internal.ssl.SSLSocketFactoryImpl
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: com.sun.ne
t.ssl.internal.ssl.SSLSocketFactoryImpl
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Unknown Source)
at HelloClient.main(HelloClient.java:16)
Caused by: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: com.sun
.net.ssl.internal.ssl.SSLSocketFactoryImpl
at java.io.ObjectInputStream.readObject0(Unknown Source)
.......


I have listed all the remaining class.



Please let me know how can I fix this problem.
Thanks.
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

It think the problem is that your SSLSocketFactory inside your RMISSLClientSocketFactory isn't serializable. You should mark that field as "transient" and restore the value inside a "readObject()" method.

For more information on how the transient keyword and readObject()/writeObject() works with Serializable objects - here's an article that covers it...
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: SSLHandshakeException
 
Similar Threads
VisualVM 1.32 doesn't connect to WAS (Websphere Application Server) 7.0.0.15
SSLHandshakeException
SSLHandshake failure with rmi
LDAPS Problem / SSLHandshakeException
Web Service client error