Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
8.5k views
in .NET FTP by (300 points)
I'm trying to use ProFTPClient to download a set of file from an FTP using the following logic. After downloading a file or two, the download fails with andf ArgumentException. I've also had it fail on the first download.

The goal is to ensure we have a local copy of every file in the remote directory. Since I am using a trial version of the API, I'm simulating copying the actual files using a much smaller file in place of the actual files.

ProFTPClient ftp = new ProFTPClient();
ftp.RemoteHost = ConfigurationSettings.AppSettings["FTP.RemoteHost"];
ftp.ControlPort = int.Parse(ConfigurationSettings.AppSettings"FTP.ControlPort"]);

ftp.ClientCertificate = ProFTPCertificate.CreateFromCER_PVK(ConfigurationSettings.AppSettings["FTP.Certificate.CER"], ConfigurationSettings.AppSettings["FTP.Certificate.PVK"], ConfigurationSettings.AppSettings["FTP.Certificate.Password"]);
ftp.ServerValidation = ProFTPClient.ServerValidationType.None;
ftp.Connect();
ftp.Auth(ProFTPClient.SecurityMechanism.TLS, true);

ftp.Login(ConfigurationSettings.AppSettings["FTP.UserName"], ConfigurationSettings.AppSettings["FTP.Password"]);

ftp.DeleteOnFailure = true;
ftp.TransferType = FTPTransferType.ASCII;

ftp.ChDir("Outbound");
foreach(string fileName in ftp.Dir("*.xml", false))
{
   if (!File.Exists(fileName))
   {
      if (File.Exists("file.tmp"))
         File.Delete("file.tmp");
      ftp.Get("file.tmp", "SmallFile.xml");
      File.Move("file.tmp", fileName);   
   }
}


The program is unable to complete successfully. The program will download a file or two and then terminate with an ArgumentException. There is no pattern as to how many successful downloads occur before encountering this error. And note that all Get() are actually downloading the exact same file.

I've enabled DEBUG logging which results in the following output. In this run, there was one successfully download and on the second Get() the exception was raised.


INFO [EnterpriseDT.Net.Ftp.Pro.ProFTPClient] 15 Dec 2004 10:47:43.499 : Licence expiry date: 1/14/2005
INFO [EnterpriseDT.Net.Ftp.Pro.ProFTPClient] 15 Dec 2004 10:47:43.499 : Trial license
DEBUG [EnterpriseDT.Net.Ftp.Pro.ProFTPClient] 15 Dec 2004 10:47:43.655 : Connecting to ftps.xxxxxx.com:990
DEBUG [EnterpriseDT.Net.Ftp.Pro.ProFTPClient] 15 Dec 2004 10:47:43.655 : ftps.xxxxxx.com resolved to xxx.xxx.xxx.xxx
DEBUG [cl] 15 Dec 2004 10:47:43.671 : Connecting directly to ftp-server xxx.xxx.xxx.xxx:990
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 15 Dec 2004 10:47:43.921 : 220-ftps.xxxxxx.com X2 WS_FTP Server 3.00 (3316436403)
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 15 Dec 2004 10:47:44.233 : 220-You've connected to Xxxxxxx.Com Secure FTP Site
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 15 Dec 2004 10:47:44.233 : 220-at ftps.xxxxxx.com yyy.yyy.yyy.yyy
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 15 Dec 2004 10:47:44.233 : 220-The maximum number of users allowed is: 100
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 15 Dec 2004 10:47:44.233 : 220-The current number of users is : 3
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 15 Dec 2004 10:47:44.296 : 220 ftps.xxxxxx.com X2 WS_FTP Server 3.00 (3316436403)
DEBUG [cl] 15 Dec 2004 10:47:44.296 : Created control-socket: ImplicitFTPS=False, SocksContext=, RemoteHost=0, controlPort=xxx.xxx.xxx.xxx, timeout=990, CompatibilityFlags=0
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 15 Dec 2004 10:47:44.312 : ---> AUTH TLS
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 15 Dec 2004 10:47:44.921 : 234 SSL enabled and waiting for negotiation
DEBUG [cl] 15 Dec 2004 10:47:44.921 : Beginning d handshake on control-channel. DEBUG [cl] 15 Dec 2004 10:47:45.655 : d handshake complete.
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 15 Dec 2004 10:47:45.655 : ---> PBSZ 0
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 15 Dec 2004 10:47:45.827 : 200 PBSZ=0
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 15 Dec 2004 10:47:45.827 : ---> PROT P
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 15 Dec 2004 10:47:46.108 : 200 PRIVATE data channel protection level set
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 15 Dec 2004 10:47:46.171 : ---> USER zzzzzzz
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 15 Dec 2004 10:47:46.312 : 331 Password required
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 15 Dec 2004 10:47:46.312 : ---> PASS ********
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 15 Dec 2004 10:47:46.499 : 230-user logged in
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 15 Dec 2004 10:47:46.780 : 230-Welcome zzzzzzz
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 15 Dec 2004 10:47:46.780 : 230 user logged in
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 15 Dec 2004 10:47:46.780 : ---> TYPE A
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 15 Dec 2004 10:47:46.999 : 200 Type set to ASCII.
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 15 Dec 2004 10:47:46.999 : ---> CWD Outbound
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 15 Dec 2004 10:47:47.202 : 250 CWD successful
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 15 Dec 2004 10:47:47.202 : ---> PASV
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 15 Dec 2004 10:47:47.483 : 227 Entering Passive Mode (xxx,xxx,xxx,xxx,10,114).
DEBUG [cl] 15 Dec 2004 10:47:47.499 : Connecting directly to ftp-server xxx.xxx.xxx.xxx:2674
DEBUG [an] 15 Dec 2004 10:47:47.749 : Created passive data-socket: Protocol=d, SocksConnector=, CompatibilityFlags=0, UseSSLClosure=False, WaitOnClose=False
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 15 Dec 2004 10:47:47.749 : ---> NLST *.xml
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 15 Dec 2004 10:47:47.952 : 150 Opening ASCII data connection for directory listing
DEBUG [an] 15 Dec 2004 10:47:47.952 : Beginning d handshake on passive data-channel
DEBUG [an] 15 Dec 2004 10:47:49.046 : Handshake complete
DEBUG [an] 15 Dec 2004 10:47:49.780 : Attempt to close unconnected passive data-channel.
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 15 Dec 2004 10:47:49.874 : 226 transfer complete
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 15 Dec 2004 10:47:49.874 : ---> PASV
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 15 Dec 2004 10:47:50.046 : 227 Entering Passive Mode (xxx,xxx,xxx,xxx,10,115).
DEBUG [cl] 15 Dec 2004 10:47:50.046 : Connecting directly to ftp-server xxx.xxx.xxx.xxx:2675
DEBUG [an] 15 Dec 2004 10:47:50.265 : Created passive data-socket: Protocol=d, SocksConnector=, CompatibilityFlags=0, UseSSLClosure=False, WaitOnClose=False
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 15 Dec 2004 10:47:50.265 : ---> RETR SmallFile.xml
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 15 Dec 2004 10:47:50.515 : 150 Opening ASCII data connection for SmallFile.xml (1115 bytes)
DEBUG [an] 15 Dec 2004 10:47:50.530 : Beginning d handshake on passive data-channel
DEBUG [an] 15 Dec 2004 10:47:51.249 : Handshake complete
DEBUG [EnterpriseDT.Net.Ftp.FTPControlSocket] 15 Dec 2004 10:47:52.187 : 226 transfer complete
DEBUG [EnterpriseDT.Net.Ftp.FTP

10 Answers

0 votes
by (162k points)
Do you know what type of FTPS server you are connecting to?

Also, does Example 1 (included in the distro) work against this server?

thanks
0 votes
by (300 points)
According to the logs above, the server I'm connecting to is WS_FTP Server 3.00. This is consistent with what I have been told.

When I run Example 1 against that server, I get:

ERROR [NonvalidatingClient] 15 Dec 2004 12:54:52.093 : Caught exception Enterpri
seDT.Net.Ftp.FTPException 'AUTH TLS': command not understood
   at EnterpriseDT.Net.Ftp.FTPControlSocket.ValidateReply(FTPReply reply, String
[] expectedReplyCodes)
   at EnterpriseDT.Net.Ftp.Pro.ProFTPClient.Auth(SecurityMechanism securityMecha
nism, Boolean secureDataChannels)
   at EnterpriseDT.Net.Ftp.Pro.ProFTPClient.Auth(SecurityMechanism securityMecha
nism)
   at NonvalidatingClient.Main(String[] args)
0 votes
by (162k points)
We'll get back to you ASAP - we'll run some tests against WS_FTP. We have worked with WS_FTP against our Java clients for some time, so this shouldn't be too difficult to figure out.

According to the logs above, the server I'm connecting to is WS_FTP Server 3.00. This is consistent with what I have been told.

When I run Example 1 against that server, I get:

ERROR [NonvalidatingClient] 15 Dec 2004 12:54:52.093 : Caught exception Enterpri
seDT.Net.Ftp.FTPException 'AUTH TLS': command not understood
   at EnterpriseDT.Net.Ftp.FTPControlSocket.ValidateReply(FTPReply reply, String
[] expectedReplyCodes)
   at EnterpriseDT.Net.Ftp.Pro.ProFTPClient.Auth(SecurityMechanism securityMecha
nism, Boolean secureDataChannels)
   at EnterpriseDT.Net.Ftp.Pro.ProFTPClient.Auth(SecurityMechanism securityMecha
nism)
   at NonvalidatingClient.Main(String[] args)
0 votes
by (51.6k points)
We've run a test similar to the one you described and got the same problem. We have identified the cause of the problem, which was a bug in our SSL/TLS software, and will be able to e-mail you a fixed version. Could you please e-mail support so that we can know which e-mail address to send it to?

Thanks,
Hans (EDT)
0 votes
by (162k points)
i.e. send an email to support at enterprisedt dot com

We've run a test similar to the one you described and got the same problem. We have identified the cause of the problem, which was a bug in our SSL/TLS software, and will be able to e-mail you a fixed version. Could you please e-mail support so that we can know which e-mail address to send it to?

Thanks,
Hans (EDT)
0 votes
by (300 points)
Thanks for the quick turn around. The new version appears to work fine.

Great service for just the trial version. Looking forward to getting a licensed copy once our purchasing department does whatever they need to do.
0 votes
by (162k points)
Thanks for finding this problem. We will release this as 1.0.1 on Friday.

Thanks for the quick turn around. The new version appears to work fine.

Great service for just the trial version. Looking forward to getting a licensed copy once our purchasing department does whatever they need to do.
0 votes
by (140 points)
I have taken over for "FlyingGMan" on this project. We have now bought the licensed edtFTPnet/PRO product (version 1.0.3), and it works great when we run as the logged-on user. However, one of our requirements is the ability to perform the Secure FTP operation while running under the context of a service account. When I try to do this by running it in Windows Scheduled Tasks, I get the following error message and stack trace:
Exception: System.ArgumentException
Message: If a certificate is specified, it must have a private key.
Source: edtftpnet-pro-1.0.3
at a3.a(cm A_0)
at q.c()
at EnterpriseDT.Net.Ftp.Pro.ProFTPClient.Auth(SecurityMechanism securityMechanism, Boolean secureDataChannels)
at Kindred.Monster.Util.FTP.GetFTPClient()
at Kindred.Monster.MonsterExtract.UploadFile() in c:\source\iisd\monster\securityupload\securityupload.cs:line 170
at Kindred.Monster.MonsterExtract.ProcessData() in c:\source\iisd\monster\securityupload\securityupload.cs:line 54
at Kindred.Common.Batch.BatchBase.Run(String[] args)


The code we are using in GetFTPClient is as follows:

ProFTPClient ftp = new ProFTPClient();
ftp.RemoteHost = "hostname";
ftp.ControlPort = portnumber;
ftp.ClientCertificate = ProFTPCertificate.CreateFromCER_PVK("ftpskindred.crt", "ftpskindred.pvk", "XXXXX");
ftp.ServerValidation = ProFTPClient.ServerValidationType.None;
ftp.Connect();
ftp.Auth(ProFTPClient.SecurityMechanism.TLS, true);
ftp.Login(username, password);
return ftp;


The ftpskindred.crt and ftpskindred.pvk files exist in the same directory as our EXE and the edtftpnet-pro-1.0.3.dll, as well as the ftpskindred.csr and ftpskindred.key files that I think were used to create the CRT file.

Can you help?
0 votes
by (162k points)
We have someone else who has experienced the same problem - and it looks like one of our suggestions worked for them. We'll post what worked as soon as they confirm it.

Exception: System.ArgumentException
Message: If a certificate is specified, it must have a private key.
0 votes
by (51.6k points)
I have replied to this message in the new topic Using edtFTPnet/PRO from a service.

- Hans (EDT Support)

Categories

...