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");
}