 |
|
 |
My remote site doesn't have anything on port 990, only on ports 21, 22, and 111.
I need to do a secure file download.
Using your sample, I get hung up doing the
SetRemotePort(990);
I've tried to do other things to download a file, but I was not successful.
I know the site's name, a valid username and password, and the file's pathname that I want to download. I don't know the steps to go through to get the file.
Thanks in advance.
|
|
|
|
 |
|
 |
Thank you very form providing wonderful help to handle sslStream security in out internal FTP Application.
I have some problem through this dll, I am able to connect secure FTP host, however unable to upload or download the files from the site, could you please help me.
Application use hung in sslStream.AunthenticationAsClient(...)
Regard
JACOB.
|
|
|
|
 |
|
 |
Hi,
I'm trying to upload a file but nothing happens.
I did exactly what you recommended on your article...
Anybody could help me?
Thank you
Here is the code
FTPFactory ftp = new FTPFactory();
ftp.setDebug(true);
ftp.setRemoteHost("Ftp://207.107.13.147/vp4603_casas/Admin/Datapacks/");
ftp.setRemotePort(22);
ftp.loginWithoutUser();
string cmd = "AUTH SSL";
ftp.sendCommand(cmd);
ftp.getSslStream();
ftp.setUseStream(true);
ftp.setRemoteUser("*****");
ftp.setRemotePass("******");
ftp.login();
ftp.setBinaryMode(false);
ftp.uploadSecure(@"C:\teste.exe", false);
ftp.close();
|
|
|
|
 |
|
 |
Hi,
I can not upload a file. It just waits forever in the line ftp.uploadSecure(@"filename", false);
This is the last messages where it waits:
READ:230 User logged on.
Connected to ftp.secureftpserver.com
WRITE:TYPE I
READ:200 Type set to I
WRITE:PASV
READ:227 Entering Passive Mode (66,220,9,51,32,80).
WRITE:PASV
READ:227 Entering Passive Mode (66,220,9,51,30,29).
This is the code:
FTPFactory ftp = new FTPFactory();
ftp.setDebug(true);
ftp.setRemoteHost("ftp.secureftpserver.com");
ftp.setRemotePort(21);
ftp.loginWithoutUser();
string cmd = "AUTH SSL";
ftp.sendCommand(cmd);
ftp.getSslStream();
ftp.setUseStream(true);
ftp.setRemoteUser("userid");
ftp.setRemotePass("password");
ftp.login();
ftp.setBinaryMode(true);
ftp.uploadSecure(@"cdfg.txt", false);
ftp.close();
TIA for you help
|
|
|
|
 |
|
 |
I get the error message "Error: A non-blocking socket operation could not be completed immediately" on this line ftp.loginWithoutUser(); My port is 990 and it is open since filezilla connects fine. I read through the thread - found folks were having similar issues but did not get a solution. Can you help?
|
|
|
|
 |
|
 |
Hi!
I downloaded this project but when a Debug him obtain an errore: "'D:\..\FTPSecure\FTPTest\FTP_DLL.csproj' cannote be opened because its project type(.csproj) is not supported by this version of the application." But I have instaled Visual Studio 2008 and Visual Studio 2010. I need download any files from FTP Secure( i have server, user, password, port, dir). Can anyone help, me?
|
|
|
|
 |
|
 |
Hello,
You have to open the Project on Visual Studio 2005
|
|
|
|
 |
|
 |
I cannot connect WithoutUseron FTP SSL site, i write that:
FTPFactory ftp = new FTPFactory();
ftp.setDebug(true);
ftp.setRemoteHost("ftps.server.com");
ftp.setRemotePort(21);
ftp.loginWithoutUser();
Where is a problem?
|
|
|
|
 |
|
 |
The Ftps port is 990 and not 21.
try to change it on 990 and re test.
Good luck.
|
|
|
|
 |
|
 |
Hi,
I've used your code but getting an exception "An existing connection was forcibly closed by remote host" during ftp,loginWithoutUser. I am sure port 990 is open because I can connect using Filezilla using TLS/SSL with that port.
Any thoughts?
JMPryde
|
|
|
|
 |
|
 |
You forgot to add the credits for the original FTPFactory class you are using in your article.
So here they are:
/*
FTPFactory.cs
Written by Jaimon Mathew (jaimonmathew@rediffmail.com)
Rolander,Dan (Dan.Rolander@marriott.com) has modified the download
method to cope with file name with path information. He also provided
the XML comments so that the library provides Intellisense descriptions.
*/
|
|
|
|
 |
|
 |
Dear mehdi!
i used your library to upload file to server. but i have "An existing connection was forcibly closed by the remote host" error when i use this code to send data to server.
ftp.upload(@"D:\UploadFileTest\dotnetfx35_1.exe", false);
and error occur in this loop
while ((bytes = input.Read(buffer,0,buffer.Length)) > 0)
{
cSocket.Send(buffer, bytes, 0);
}
when debug i see.
the fist time cSocket.Send(buffer, bytes, 0);; is pass. But when implementation the cSocket.Send(buffer, bytes, 0); second time then error occur.
If i use ftp.uploadSecure(@"D:\UploadFileTest\dotnetfx35_1.exe", false); for upload i have this error
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
Please help me fix this error.
best regard
trunghd
modified on Thursday, November 19, 2009 4:59 AM
|
|
|
|
 |
|
 |
I see.
please check those points:
-the server support FTPS connection
-The Port 990 Is open
-able to connect with login/pass
best regard,
kadaoui El Mehdi
|
|
|
|
 |
|
 |
Dear Mehdi!
Thanks for your answer.
1. I using Linux Operating System. My server is support FTPS connection.
2. The Port 990 is open.
Because i can use FileZilla Client to connect then upload and download file.
please help me. Thanks so much!
trunghd
|
|
|
|
 |
|
 |
I had the same probleme when i was developing this library.
try to check if you can connect to the FTPS server using the library. JUST THE CONNEXION.
FTPFactory ftp = new FTPFactory();
ftp.setDebug(true);
ftp.setRemoteHost(Settings.Default.TargetFtpSource);
ftp.setRemotePort(990);
ftp.loginWithoutUser();
string cmd = "AUTH SSL";
ftp.sendCommand(cmd);
ftp.getSslStream();
ftp.setUseStream(true);
ftp.setRemoteUser(Settings.Default.TargetFtpSecureUser);
ftp.setRemotePass(Settings.Default.TargetFtpSecurePass);
ftp.login();
after check if the library get succefully the "SSL certificate" from FTPS server, because if don't you can't connect to the FTPS on port 990.
ftp.getSslStream();
ftp.setUseStream(true);
Good luck.
Mehdi
|
|
|
|
 |
|
 |
Dear Mehdi!
Thanks for your quick replay.
I have login success with ftps. But my problem occur when i try to send data from client to server. I have check my upload file in my ftps space and i see it's exist on my server with 0KB.
when debug i see. in why loop. The fist package send success. But when why loop do next times this error occur.
please help me.
Thanks so much.
trunghd!
|
|
|
|
 |
|
 |
Hi,
I had this problem when i developping this library.
I think the problem is in the creation of SslSocket, so put a breakpoint on those 2 methods and debug with F11:
<pre>//Create SSL Stream
ftp.getSslStream();
ftp.setUseStream(true);
</pre>
Tell me if the SslSocket is created successfully.
Good luck.
Mehdi
|
|
|
|
 |
|
 |
Hi Mehdi,
I am getting an error as "An existing connection was forcibly closed by the remote host."
at this line of call
ftp.loginWithoutUser();
private string readLine()
{
while(true)
{
if (useStream)
bytes = stream.Read(buffer, buffer.Length, 0);
else
bytes = clientSocket.Receive(buffer, buffer.Length, 0);
exactly at the above line the error comes,
I am not sure FTP server has open the port 990.
The same error i am getting through my code as follows
FtpWebRequest request = null;
FtpWebResponse response = null;
request = (FtpWebRequest)WebRequest.Create(new Uri("ftp://ftp.example.com:990"));
request.UsePassive = true;
request.Method = WebRequestMethods.Ftp.ListDirectory;
request.Credentials = new NetworkCredential(username, password);
request.Proxy = null;
request.EnableSsl = true;
request.UseBinary = false;
request.KeepAlive = false;
request.Timeout = int.MaxValue;
request.ReadWriteTimeout = int.MaxValue; //10000000;
response = (FtpWebResponse)request.GetResponse();
But i am able to access through CoreFtp by using oprt 990 and while using CoreFtp to connect to FTP server it pops up a window which has Server certificate if i accept the certificate then i am connected to the FTP server.
Please help me what is the issue i am trying for this for couple of days.
|
|
|
|
 |
|
 |
I am getting "The remote certificate is invalid according to the validation procedure" error message at the ftp.getSslStream() line. It works great on my Vista machine, but up on the Win2003 server it fails. Very strange. Would you think you can help me with this issue?
thx
|
|
|
|
 |
|
 |
I'm trying to get a file listing from a folder, but it's returning garbage, and I can't figure out what's going on.
Here is the code that I am using. I've tried NLST, LIST, and LS, none of which have worked.
public string[] getFileList(string mask)
{
if(!logined)
{
login();
}
Socket cSocket = createDataSocket();
this.getSslDataStream(cSocket);
sendCommand("NLST " + mask);
stream2.AuthenticateAsClient(remoteHost,
null,
System.Security.Authentication.SslProtocols.Ssl3 |
System.Security.Authentication.SslProtocols.Tls,
true);
if(!(retValue == 150 || retValue == 125))
{
throw new IOException(reply.Substring(4));
}
StringBuilder mes = new StringBuilder();
while(true)
{
int bytes = cSocket.Receive(buffer, buffer.Length, 0);
mes.Append(ASCII.GetString(buffer, 0, bytes));
if(bytes < buffer.Length)
{
break;
}
}
Here are the responses that I am getting from the server.
READ:250 Directory changed to /d:/FTP_Transfer
WRITE:PASV
READ:227 Entering Passive Mode (10,0,2,24,5,102)
WRITE:NLST Edeposit
READ:150 Opening ASCII mode data connection for /bin/ls.
Server Certificate Issued To: CN=ftp.*.com
Server Certificate Issued By: CN=ftp.*.com
Server Certificate Validation Error
RemoteCertificateChainErrors
READ:226 Transfer complete.
WRITE:QUIT
READ:221 Goodbye!
The method returns this:
>
?7BC??f?i?#?,?????h?P?O?????3?g???????q?14 ?l
???#?U0#????B????.????Ku?8??y???k
Any ideas as to what's going on?
Thanks in advance.
Aaron
|
|
|
|
 |
|
 |
that means your server certification is invalid or contains some errors but if you want to accept all server certification you have to
change OnCertificateValidation &method on this:
private static bool OnCertificateValidation(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
return true;
}
it return true however is bad or good certification.
and also in <b>getSslStream(Socket Csocket)</b>, you have to replace the 2 first lines per:
ServicePointManager.ServerCertificateValidationCallback= new RemoteCertificateValidationCallback(OnCertificateValidation);
SslStream _sslStream = new SslStream(new NetworkStream(Csocket), false, new RemoteCertificateValidationCallback( OnCertificateValidation));
|
|
|
|
 |
|
 |
Thanks for the quick response.
I've done both of those things. I can upload securely to the ftp server, download from the ftp server, but the listing is the only thing that's not working for me.
I'm making sure that Type is set to A and not I. I'm using PASV. I just can't seem to narrow down what's wrong.
|
|
|
|
 |
|
 |
even if you make changes, you have always " Server Certificate error" ?
|
|
|
|
 |
|
 |
I no longer get the server certificate error, but the following line of code is still returning non-ASCII text.
mes.Append(ASCII.GetString(buffer, 0, bytes));
|
|
|
|
 |
|
 |
are you operating in Unix system ?
because when you ask an FTP server under Unix system for files list, the first line from reponse server is the "number of files" and not the first file on the list.
try to do this:
try
{
mes.Append(ASCII.GetString(buffer, 0, bytes));
}
catch
{
continue;
}
even if there is an error the program continue to run.
Good luck.
|
|
|
|
 |