|
|
Comments and Discussions
|
|
 |

|
Hi,
I am getting the below error
"Index was outside the bounds of the array."
in the readline() method
kindly help me it is urgent
host: 123.252.255.10
port: 22
private string readLine()
{
while (true)
{
if (useStream)
bytes = stream.Read(buffer, buffer.Length, 0);
else
bytes = clientSocket.Receive(buffer, buffer.Length, 0);
mes += ASCII.GetString(buffer, 0, bytes);
if (bytes < buffer.Length)
{
break;
}
}
char[] seperator = { '\n' };
string[] mess = mes.Split(seperator);
if (mes.Length > 2)
{
mes = mess[mess.Length - 2]; }</pre></pre>
|
|
|
|

|
I have the FTP class in my test project, but the authors implementation example just doesn't work as is...or at least not for me.
If anyone has a (working) basic example of using his class to connect to a SFTP server, I'd love to see it.
Thanks,
Barry
|
|
|
|

|
When, I am running the program, i am getting this error at loginwithoutuser function
base {System.Runtime.InteropServices.ExternalException} = {"An unknown, invalid, or unsupported option or level was specified in a getsockopt or setsockopt call"}
|
|
|
|

|
Hi,
I am new to this programming lanugauge, and cannot run the program as it needs and exe to execute.
Can someone share how I can do that..
Thanks
|
|
|
|

|
Mehdi,
Thank you. This program works great on my system connecting to FTP server(FTPS).
But on the client location, we need to connect to FTP server through the proxy. FileZilla client is able to connect to FTP server through the proxy settings.
Here in this program how to set these configuration work through the proxy.
Regards,
Killi
|
|
|
|

|
I downloaded the code and analyzed all of it. All of the SslStream sslStream = new SslStream(client.GetStream(), false); code is commented out. Is this still secure if I use this code?
|
|
|
|

|
Hi,
Thank you very much for the code. However, dir is not working using secure ftp. Any ideas?
Thanks,
Deb
|
|
|
|

|
The IBM FTP server I was using this class to access was freezing when trying to upload or download files. It froze on the _sslStream.AuthenticateAsClient function. The issue turned out to be the sequence of commands sent to the server. On the IBM FTP server you have to send the RETR/STOR commands first thing after creating the data transfer socket before you call the function to create the secure stream. I've edited the class a bit, but here are the revised upload and download functions I use that work with the IBM FTP server:
NOTE: The functionality to resume has been removed because our server doesn't support it. Also, you may notice the outDelegate. This is the function used to output. You can set it to any function that returns void and takes a string (Ex: Console.WriteLine).
|
|
|
|

|
I use the code successfully until it reaches for the function of readline where it throws an exception: Index and length must refer to a location within the string.\r\nParameter name: length
Please help, I ve been with that error for a week.
|
|
|
|

|
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?
|
|
|
|

|
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'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
|
|
|
|

|
Hej,
I can connect fine to my SSL secured FTP with AUTH SSL. But when trying to call
public Socket createDataSocket()
I get the Error "500 You need to use a client supporting PRET (PRE Transfer) to use PASV".
I don't know how to handle this?
But if ask Server serveral other things, that's no problem as you can see here:
SYST
215 UNIX system type.
FEAT
211-Extensions supported:
PRET
AUTH SSL
PBSZ
CPSV
SSCN
CLNT
NOOP
MLST type*,x.crc32*,size*,modify*,unix.owner*,unix.group*,x.slaves*,x.xfertime*
211 End
Help would be great!
Greetings, Andreas
|
|
|
|

|
I am new to FTPS, so this library looked like it would save me a lot of time. I am watching the code execute, and my app hangs everytime the readReply() function is called. I also notice some commented out code for SslStream in the loginWithoutUser() function. THe line is //SslStream sslStream = new SslStream(client.GetStream(), false);
Is this line needed? Does anyone know why I am getting a hang when I call the loginWithoutUser (at the readReply function).
My code looks as follows:
FTP_DLL.FTPFactory factory = new FTP_DLL.FTPFactory();
factory.setDebug(true);
factory.setRemoteHost("hostname");
//Connect to SSL Port (990)
factory.setRemotePort(990);
factory.loginWithoutUser();
//Send "AUTH SSL" Command
string cmd = "AUTH SSL";
factory.sendCommand(cmd);
//Create SSL Stream
factory.getSslStream();
factory.setUseStream(true);
//Login to FTP Secure
factory.setRemoteUser("user");
factory.setRemotePass("pass");
factory.login();
Any help would be greatly appreciated. I am wokring on a deadline for figuring this out, so the sooner the better!
Thanks
|
|
|
|

|
Hi,
I am getting error at
IPEndPoint ep = new IPEndPoint(serverHostEntry.AddressList[0], remotePort);
try
{
clientSocket.Connect(ep);
}
as "A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 000.0.000.000:990"
I get above error when i use remortPort=990.
When I changed remortPort=21 it got connected to socket, but getting error in getSslStream(Socket Csocket)
_sslStream.AuthenticateAsClient(
remoteHost,
null,
System.Security.Authentication.SslProtocols.Ssl3 | System.Security.Authentication.SslProtocols.Tls,
true);
Do you have any solution to make it work with port=990.
Thanks in advance.
"Unable to read data from the transport connection: A non-blocking socket operation could not be completed immediately."
hi
|
|
|
|

|
brian64p was correct ==> (Click here)
"The FTP server wouldn't respond to authentication sent over
the data connection until the command that initiated
the data transfer was given.
The correct sequence (for those that come after) was PASV command,
open socket/stream, send command to request data, validate stream."
===============================
Here what I did to fix the problem AuthenticateAsClient()
I declare stream2 as SslStream (
private SslStream stream2;
I created a new function called getSslDataStream
public void getSslDataStream(Socket Csocket) {
SslStream _sslStream = new SslStream(new NetworkStream(Csocket));
stream2 = _sslStream;
}
Then in the uploadSecure function right after issuing the command STOR
public void uploadSecure(string fileName, Boolean resume) {
....
Socket cSocket = createDataSocket();
isUpload = true;
this.getSslDataStream(cSocket);
....
sendCommand("STOR " + Path.GetFileName(fileName)) stream2.AuthenticateAsClient(remoteHost,
null,
System.Security.Authentication.SslProtocols.Ssl3 |
System.Security.Authentication.SslProtocols.Tls,
true);
if (stream2.IsAuthenticated) {
if (!(retValue == 125 || retValue == 150)) {
throw new IOException(reply.Substring(4));
}
.....
this.stream2.Close();
}
if (cSocket.Connected)
{
cSocket.Close();
}
readReply();
......
}
}
Hopefully, this will save somebody 2 days of reading about FTP file over SSL & trying out the code in variety of ways.
|
|
|
|

|
I m trying to use the library to connect to an non secure ftp, but i got some error can you
show me an example of a non secure ftp connection.
Thx
|
|
|
|

|
In order to get any of this code to work won't I need an FTP client and server that support secure FTP? I am confused by postings on various forums where people claim that the FTP service on Windows 2003 Server does not support SFTP of FTPS and that only FTPS is natively supported on Windows 2008 Server.
Are you saying that one could technically just establish an SSL connection using the code you provided and as long as the IIS FTP server is using the SSL port everthing sent over that connection is secure?
Also, does this method support digital certificates and encryption?
Thanks!
|
|
|
|

|
Hi
When I am trying to connect my FTPS server, I get NotImplementedException. How can I solve this?
|
|
|
|

|
Can these code be used for Explicit SSL?
I tried changing the port from 990 to 21 but I get the error "Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
"
What else do I need to do?
Thank you
|
|
|
|

|
Hi, I've tried this code, The clientSocket connects to port 990 of my FTP server and my FTP server sends the welcome message... but this code seems to hang without receiving the welcome message...
private string readLine()
{
.
.
bytes = clientSocket.Receive(buffer, buffer.Length, 0);
.
.
}
Any ideas?
Regards
John
|
|
|
|

|
I am a little new to SSL. What is interesting is that I have FTP with SSL client on my testing machine and I am able to log into the server. When I use this code I get the following Error: The remote certificate is invalid according to the validation procedure which comes from line 374
_sslStream.AuthenticateAsClient(
remoteHost,
null,
System.Security.Authentication.SslProtocols.Default,
true);
I see that the second value sent to this method is a certCollection and I am wondering if this cert collection is needed to authenticate this?
Thanks much for your help, if you need more information i can provide that as well!
|
|
|
|

|
I'm getting an Index out of bounds issue in readLine() on line number 945 or mes = mess[mess.Length-2];
mess.Length = 1 and the value is "SSH-2.0-OpenSSH_3.1p1" On the server I'm connecting to.
Any Ideas?
Thanks
|
|
|
|

|
I am recieveing the error message: "The requested name is valid, but no data of the requested type was found" at the following line
FTP ftp = new FTP();
ftp.debug = true;
ftp.remoteHost = "ftp://.../";
ftp.remotePort = 990;
<big>ftp.loginWithoutUser();</big> <-- Error here
string cmd = "AUTH SSL";
ftp.sendCommand(cmd);
When debugging through it the line in the FTP class that is throwing the excetioin is
IPEndPoint ep = new IPEndPoint(Dns.Resolve(remoteHost).AddressList[0], remotePort);
Not really sure what this may mean, any help would be great.
Thanks!
Devin Sackett
|
|
|
|

|
Is there a reason that no downloadSecure method exists?
Thx & regards
|
|
|
|

|
One of FTPS servers I am using requires private key. In CuteFTP pro, there is a place for you to point to the location of the private key. I can't seem to find a way to do this in FTP secure client library?
|
|
|
|

|
Thanks alot for this article. I've been looking for something to do raw ftp in .net and this works great!
Been struggling with the ftpWebRequest today and this feels much more "controllable"
Quick (maybe studpid) question - why do you force passive mode on createDatasocket()?
Wouldn't it be better to set it up as an option to choose between active / passive mode?
Thanks again - great work
|
|
|
|

|
Hangs at the second call to AuthenticateAsClient() in GetSSLStream().
Everything connects, logs in, changes directory, etc., but once I call UploadSecure, that's where I get a hang.
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
How to implement an FTP secure connection with an SSL stream class.
| Type | Article |
| Licence | CPOL |
| First Posted | 10 Dec 2008 |
| Views | 150,937 |
| Downloads | 5,718 |
| Bookmarked | 106 times |
|
|