• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

FTPS / FTP over SSL with Jakarta Commons Net

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I do not manage FTPS / FTP over SSL jet with Commons Net.

See my code below. Executing it leads to this error:

Could not connect to server.
javax.net.ssl.SSLException: No available certificate or key corresponds to the SSL cipher suites which are enabled.
at com.sun.net.ssl.internal.ssl.SSLServerSocketImpl.checkEnabledSuites(SSLServerSocketImpl.java:307)
at com.sun.net.ssl.internal.ssl.SSLServerSocketImpl.accept(SSLServerSocketImpl.java:253)
at org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:489)
at org.apache.commons.net.ftp.FTPSClient._openDataConnection_(FTPSClient.java:494)
at org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:2296)
at org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:2269)
at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2046)
at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2093)
at tests.ftps.CommonsNetFTPSTest.main(CommonsNetFTPSTest.java:68)
BUILD SUCCESSFUL (total time: 7 seconds)

FTPS with Filezilla works fine.
Connection details: FTP over implicit TLS / SSL
Any idea what exactly to do to get this code running?

Thorsten

---------------------------------------8<---------------------------------------

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import org.apache.commons.net.PrintCommandListener;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPReply;
import org.apache.commons.net.ftp.FTPSClient;

public class CommonsNetFTPSTest
{
public static void main(String[] args) throws Exception
{
System.setProperty("javax.net.debug", "ssl");

String server = "server";
String username = "username";
String password = "password";
String remoteFile = "remotefile";
String localFile = "localfile";
String protocol = "TLS"; // TLS / SSL
int port = 990;
int timeoutInMillis = 3000;
boolean isImpicit = true;

FTPSClient client = new FTPSClient(protocol, isImpicit);

client.setDataTimeout(timeoutInMillis);
client.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out)));

try
{
int reply;

client.connect(server, port);

client.login(username, password);
client.setFileType(FTP.BINARY_FILE_TYPE);

client.execPBSZ(0);
client.execPROT("P");

System.out.println("Connected to " + server + ".");

reply = client.getReplyCode();

if (!FTPReply.isPositiveCompletion(reply))
{
client.disconnect();
System.err.println("FTP server refused connection.");
System.exit(1);
}

client.listFiles();

boolean retrieved = client.retrieveFile(remoteFile, new FileOutputStream(localFile));

}
catch (Exception e)
{

if (client.isConnected())
{
try
{
client.disconnect();
}
catch (IOException ex)
{
ex.printStackTrace();
}
}
System.err.println("Could not connect to server.");
e.printStackTrace();
return;
}
finally
{
System.out.println("# client disconnected");
client.disconnect();
}
}
}
 
We don't have time for this. We've gotta save the moon! Or check this out:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic