Discuss (FTP) and (SFTP, FTPS and SCP), our Java file transfer clients.
no avatar
User

Rashmi

Posts

5

Joined

Mon May 17, 2010 7:26 pm

Switch between normal FTP and SSLTLS

by Rashmi » Wed Jul 21, 2010 1:43 am

Hi,

Could anyone tell me if there is any easier way to switch between SSL/TLS and normal FTP other than changing the code to establish a normal connection. Like enable or disable SSL/TLS using a flag?

Because if I turned off SSL/TLS in the server, the client( java code ) would still be expecting an SSL connection.

Thanks
no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

Re: Switch between normal FTP and SSLTLS

by support2 » Wed Jul 21, 2010 8:28 am

Yes, you can use the CCC command to turn off SSL/TLS (see ccc() in SSLFTPClient) on the control channel.

Once off it can't be switched back on again.
no avatar
User

Rashmi

Posts

5

Joined

Mon May 17, 2010 7:26 pm

ccc() command: 500 Syntax error, command unrecognized.

by Rashmi » Wed Jul 21, 2010 8:10 pm

Hi
I get an error as below when I include the ccc() command in my code. Not sure what I'm doing wrong?

FTPException caught connecting to localhost:21 (FTPThread.java-527)
com.enterprisedt.net.ftp.FTPException: 500 Syntax error, command unrecognized.
at com.enterprisedt.net.ftp.FTPControlSocket.validateReply(Unknown Source)
at com.enterprisedt.net.ftp.ssl.SSLFTPClient.ccc(Unknown Source)
at com.cypherit.bbrad.server.jobs.FTPThread.initialiseFTPConnection(FTPThread.java:483)
at com.cypherit.bbrad.server.jobs.FTPThread.run(FTPThread.java:667)



Code snippet where I have included the ccc() command:

ftp = new SSLFTPClient();
messageCollector = new FTPMessageCollector();
ftp.setMessageListener(messageCollector); // ensure that we get logging


ftp.setRemoteHost( recipientHost.getHostName() );

/* Set the timeout, if no timeout is specified in the ini file
* then set the timeout to 30 seconds
*/
if (bbRadConfig.getFTPTimeout() != -1)
ftp.setTimeout(bbRadConfig.getFTPTimeout());
else
ftp.setTimeout(30000);
ftp.setRemotePort( controlPort );

/*
* Validate server.
* The validator assumes commonName is set as hostname and validation fails
* if this does not match. You have to force the validator to check for a different
* commonName by passing the commonName variable.
*/
ftp.setValidateServer(false); // you can skip server validation by setting it to false. Default is true
if(commonName != null && !commonName.equals(""))
ftp.setCustomValidator(new SSLFTPStandardValidator(commonName));

ftp.getRootCertificateStore().importPEMFile(certificateFile);
ftp.connect();
ftp.auth(SSLFTPClient.AUTH_TLS);


if(!recipientHost.getProtocol().equals(RecipientHost.PROTOCOL_SSLTLSFTP))
{
ftp.ccc();
}


Thanks
Rashmi
no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

Re: ccc() command: 500 Syntax error, command unrecognized.

by support2 » Wed Jul 21, 2010 11:37 pm

Not all servers support the CCC command. It appears that yours doesn't.

Who is online

Users browsing this forum: No registered users and 142 guests

Powered by phpBB ® | phpBB3 Style by KomiDesign