Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

RMI SSL -- Wireshark detect plaintext

843793Mar 6 2009 — edited Apr 2 2009
Hi all newbie here.

I implemented a RMI server client application, and used custom socket factories for the SSL as stated in the tutorial itself. I manage to get the RMI part working, and checked the debug information from the SSL itself, and if I'm not wrong the handshake is completed as well.

But when I tried to sniff the packets sent from my laptop to a friend's in which the connection is made, I manage to see the text I sent in plaintext instead of being encrypted.

Please help, thanks in advance. Let me know if I need to include any code / debug information.

The Server
public class PokerServer extends UnicastRemoteObject implements PokerInterface, ChatInterface {

    private static final int PORT = 9999; //Defines the port number
	private ServerList serverList = new ServerList();
	private static Registry registry;


    public PokerServer() throws Exception {
		super(PORT, *new RMISSLClientSocketFactory(), new RMISSLServerSocketFactory()*);
    }

	//testing method
    public String sayHello() {
		return "\n Helloooooooooooooooo";
    }
	
	public static void createSSLRegistry() {
		// Create SSL-based registry
		try {
	    registry = LocateRegistry.createRegistry(PORT,
		new RMISSLClientSocketFactory(),
		new RMISSLServerSocketFactory());  

		} catch (Exception e) {
			System.out.println("PokerServer err: " + e.getMessage());
			e.printStackTrace();
		}
	}
	
    public static void main(String args[]) {
		//Loads the policy
		System.setProperty("java.security.policy","policy");
		
		// Create and install a security manager
		if (System.getSecurityManager() == null) {
		    System.setSecurityManager(new RMISecurityManager());
		}
		try {
			//calls the creation of SSLRegistry
			createSSLRegistry();
		    PokerServer obj = new PokerServer();
			
		    // Bind this object instance to the name "PokerServer"
		    registry.rebind("PokerServer", obj);
		    System.out.println("PokerServer bound in registry");
		} 	catch (java.net.MalformedURLException e) {
			System.out.println("PokerServer err: Malformed URL for "
			    + e.toString());
		}	catch (RemoteException e) {
			System.out.println("PokerServer err: Communication error "
			+ e.toString());
		}	catch (Exception e) {
		    System.out.println("PokerServer err: " + e.getMessage());
		    e.printStackTrace();
		}
    } //end of main
}
The client
public static void getSSLRegistry() {
		try {
				
		// Make reference to SSL-based registry
		registry = LocateRegistry.getRegistry(
		"127.0.0.1", PORT,
		new RMISSLClientSocketFactory());
		} catch (Exception e) {
			System.out.println("PokerClient exception: " + e.getMessage());
			e.printStackTrace();
		}
	}
	
	private static void textTyped() {
        try {
		textString = userInput.readLine();
			try {
					if (name != null && textString.equals("/exit")) {
						chatServer.leaveServer(displayChat, name);
						System.exit(0);
					}
				}  catch (Exception ex) {
					System.out.println("Exit failed.");
				}
			   if (firstMessage) { 
				   name = textString;
				   chatServer.joinServer(displayChat,name);
				   firstMessage = false;
			   } else { chatServer.sendMessage(name, textString); }
        	}   catch (Exception ie) {
        		   System.out.println("Failed to send message.");
        	}
            textString = "";
    } //end of textTyped
	
	
    public static void main(String args[]) {
	try {
		//Show SSL Debug information
		System.setProperty("javax.net.debug","all,ssl,data,verbose,packet,record");
		
		System.setProperty("javax.net.ssl.trustStore", "truststore");
		System.setProperty("javax.net.ssl.trustStorePassword","trustword");
	    //calls the getSSLRegistry()
		getSSLRegistry();
	    // "server" is the identifier that we'll use to refer
	    // to the remote object that implements the "PokerInterface"
	    // interface
	    PokerInterface server = (PokerInterface) registry.lookup("PokerServer");
		chatServer = (ChatInterface) server;
		displayChat = new DisplayMessage();
		
	    String message = "blank";
	    message = server.sayHello();
	    System.out.println(message+"\n");
		
		while (true) 
		{textTyped();}
		
	} catch (Exception e) {
	    System.out.println("PokerClient exception: " + e.getMessage());
	    e.printStackTrace();
	}
    }
Thanks for your time!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 30 2009
Added on Mar 6 2009
38 comments
2,621 views