commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jthistle <jthis...@jtmconcepts.com>
Subject Re: FTPS Connect Help
Date Tue, 14 Jul 2009 15:38:44 GMT

Thank you very much. It is an implicit connection and I didn't tell it that
in "ftpsClient = new FTPSClient(protocol,true);" once that was added it
connected right away.  SSL is what my superviser wants me to use, even
though TLS is better... Again, thank you for your help.

-Jordan


Steve Cole-6 wrote:
> 
> 1. Are you sure you want to use SSL instead of TLS for the protocol?
> 2. Is it implicit or explicit?
> 3. Are you using the correct port? 990 is typical.
> 
> Here's how my implementation connects...
> 
> String protocol        = "TLS";    // SSL/TLS
> 
> FTPSClient ftpsClient = null;
> if (implicit){
>   ftpsClient = new FTPSClient(protocol,true);
> }else{
>   ftpsClient = new FTPSClient(protocol,false);
> }
> ftpsClient.connect(server,port);
> 
> If you don't set the KeyManager, your FTPSClient won't present a client
> certificate for authentication.
> If you don't set the TrustManager, your FTPSClient won't verify the server
> you're connecting to.
> 
> ----- Original Message ----- 
> From: "Jthistle" <jthistle@jtmconcepts.com>
> To: <user@commons.apache.org>
> Sent: Tuesday, July 14, 2009 8:41 AM
> Subject: FTPS Connect Help
> 
> 
>>
>> Hello,
>> I am trying to use apache commons to connect to my data server using FTPS
>> over SSL. The code runs fine until it tries to connect to the server
>> "ftpsClient.connect(server, port);" at which point the code sits there
>> for
>> several minutes until a socket exception is thrown that says "Connection
>> Reset", presumably from timing out.  I am using a self-signed certificate
> if
>> that makes a difference.  When I connect to the server using Filezilla it
>> takes just a few seconds to connect using SSL from the same computer I'm
>> running my java program, so it shouldn't be a network problem.  I've
> placed
>> my code below, any help would be greatly appreciated.
>>
>> Thank you in advance,
>> -Jordan
>>
>> --------------------------------------------------------------------------
> ------
>> import java.io.FileNotFoundException;
>> import java.io.FileOutputStream;
>> import java.io.IOException;
>> import java.io.OutputStream;
>> import java.io.PrintWriter;
>> import java.net.SocketException;
>> import java.security.NoSuchAlgorithmException;
>> import org.apache.commons.net.PrintCommandListener;
>> import org.apache.commons.net.ftp.FTPConnectionClosedException;
>> import org.apache.commons.net.ftp.FTPFile;
>> import org.apache.commons.net.ftp.FTPSClient;
>>
>> public class FileTransferFTPS implements IFileTransfer
>> {
>>     private FTPSClient ftpsClient;
>>     boolean tracer = true;
>>     private String server;
>>     private String user;
>>     private String pass;
>>     private int port;
>>     private Log log = Main.getLog();
>>     private int j = 0;
>>
>>     /**
>>      *  This method tries to connect & logon to the server, and
>>      *  returns a Boolean true upon success and false upon failure
>>      *
>>      *  @param serverName           Name of the server to connect to
>>      *  @param userName             Username to use
>>      *  @param password             password to use
>>      *
>>      *  @return boolean             true on connected,
>>      *                              false if unable to connect
>>      */
>>     public boolean connect(String serverName, int connectionPort, String
>> userName,
>>             String password)
>>     {
>>         if(tracer) System.out.println("FileTransferFTPS.connect()");
>>         server = serverName;
>>         user = userName;
>>         pass = password;
>>         port = connectionPort;
>>         boolean success;
>>
>>         try {
>>             ftpsClient = new FTPSClient("SSL");
>>             ftpsClient.addProtocolCommandListener(new
>> PrintCommandListener(new PrintWriter(System.out)));
>>
>>         }
>>         catch (NoSuchAlgorithmException ex) {
>>             return false;
>>         }
>>
>>         try {
>>             /* Can't write to textArea if textArea doesn't exist yet
>>              * Occurs during a test connection */
>>             try{
>>                 log.writeTextArea("Connecting...\n");
>>             }catch(NullPointerException ex){
>>         }
>>
>>             ftpsClient.connect(server, port);
>>             ftpsClient.enterLocalPassiveMode();
>>             success = ftpsClient.login(user, pass);
>>         }
>>         catch (SocketException ex) {
>>             System.out.println(ex.getMessage());
>>             return false;
>>         }
>>         catch (IOException ex) {
>>             return false;
>>         }
>>
>>         return success;
>>     }
>> -- 
>> View this message in context:
> http://www.nabble.com/FTPS-Connect-Help-tp24478702p24478702.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
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/FTPS-Connect-Problem-tp24478702p24482065.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