ConnectIOException trying RMI over SSL

Hi,

I'm making a RMI application and try to secure it with SSL. I read the tutorial on blogs.sun.com/lmalventosa/entry/using_the_ssl_tls_based. Any help will be greatfull.

error:

java.rmi.ConnectIOException: Exception creating connection to: 80.201.202.59; nested exception is:

java.net.SocketException: Default SSL context init failed:null

at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:587)

at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185)

at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:171)

at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:306)

at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)

at server.communication.ClientProcessing.startServer(ClientProcessing.java:118)

at server.Server.main(Server.java:21)

Caused by: java.net.SocketException: Default SSL context init failed:null

at javax.net.ssl.DefaultSSLSocketFactory.createSocket(SSLSocketFactory.java:156)

at javax.rmi.ssl.SslRMIClientSocketFactory.createSocket(SslRMIClientSocketFactory.java:105)

at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:569)

... 6 more

My code is:

publicclass ClientProcessingextends UnicastRemoteObjectimplements Communicate{

privatestaticfinalint PORT = 8888;

public ClientProcessing()throws RemoteException{

super(0,new SslRMIClientSocketFactory(),new SslRMIServerSocketFactory(null,null,true));

}

publicstaticvoid startServer(){

if(System.getSecurityManager() ==null){

System.setSecurityManager(new RMISecurityManager());

}

System.setProperty("javax.net.ssl.keyStore","server.keystore");

System.setProperty("javax.net.ssl.keyStorePassword","xxx");

System.setProperty("javax.net.ssl.trustStore","server.keystore");

System.setProperty("javax.net.ssl.trustStorePassword","xxx");

try{

LocateRegistry.createRegistry(PORT,new SslRMIClientSocketFactory(),

new SslRMIServerSocketFactory(null, null,true));

}catch(Exception e){

System.err.println("create Registry error");

thrownew Error("Error creating RMI registry",e);

}

/**

* Wait 2000ms so that registry is created before Server is started

*/

try{

Thread.sleep(2000);

}catch(Exception e){

System.err.println("Error with sleeping in Runnable");

}

try{

String name ="server";

Communicate stub =new ClientProcessing();

Registry registry = LocateRegistry.getRegistry(null,PORT,new SslRMIClientSocketFactory());

registry.rebind(name, stub);

}catch (Exception e){

e.printStackTrace();

}

}

}

Message was edited by:

VOP

[4829 byte] By [VOPa] at [2007-11-27 2:40:45]
# 1
Something wrong with those keystore or truststore settings.BTW that sleep is unnecessary. When createRegistry() returns, the Registry is exported and ready to receive calls.
ejpa at 2007-7-12 3:03:54 > top of Java-index,Core,Core APIs...