Skip to Main Content

Java Security

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!

startHandshake() hangs on FTPS Client implementation

843811Oct 27 2006 — edited Jul 6 2009
Hi,

I'm working on developing a small FTPS client test program that connects to an FTP server using explicit SSL. I first connect with a standard socket, then send the message
"AUTH TLS"
I get back
"234 AUTH TLS-C/TLS OK."
meaning the server is ready to switch to a secure connection. Immediately after, I call the startHandshake() method and that's where the process gets stuck (or if I set the timeout interval to a minute it'll eventually time out.) I can connect fine with SecureFTP (based on Java) to the FTP Server using the same host, port, and with explicit SSL. Any ideas on what could cause this?

Here's a relevant portion of the code based off of the Apache FTPClient source:

From my test file:
FtpsClient peoplesFTP = new FtpsClient();
peoplesFTP.connect(HOST, PORT);
Which calls this inside FtpsClient.java
public void connect(String address, int port) throws SocketException, IOException
	{
		super.connect(address, port);
		System.out.println(this.getReplyString());
		this.secure();
	}
And the secure method inside Ftpsclient.java
public void secure() throws IOException
	{
		this.sendCommand("AUTH", "TLS");

		System.out.println(this.getReplyString());
		SSLSocket socket = (SSLSocket) this.context.getSocketFactory().createSocket(this._socket_, this.getRemoteAddress().getHostAddress(), this.getRemotePort(), true);
		socket.setSoTimeout(10000);
		try {
			socket.startHandshake();
		} catch (SocketTimeoutException e) {
			System.out.println("Socket timed out");
		}

		this._socket_ = socket;
		this._controlInput = new BufferedReader(new InputStreamReader(socket.getInputStream(), getControlEncoding()));
		this._controlOutput = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(), getControlEncoding()));

		this.setSocketFactory(new FtpsSocketFactory(this.context));
	
		this.sendCommand("PBSZ", "0");
		this.sendCommand("PROT", "P");
	}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 3 2009
Added on Oct 27 2006
14 comments
1,741 views