commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Keishin <inbo...@web.de>
Subject FTPS / FTP over SSL with Jakarta Commons Net
Date Fri, 20 Nov 2009 10:18:11 GMT

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?


---------------------------------------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();
        }
    }
}
 
-- 
View this message in context: http://old.nabble.com/FTPS---FTP-over-SSL-with-Jakarta-Commons-Net-tp26436546p26436546.html
Sent from the Commons - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message