Réception d'un EOF inattendu ou de 0 octet du flux de transport

Jan 12, 2012 at 2:36 PM

Hello Alex.

 

I'm using your library on a project.

When I try to communicate with the customers FTP Server I receive that message.

I'll send my code:

public static void Connect_ToFtpWithSSLEnabled_ConnectsSuccessfully()        {          

 try           

{               

using (FTPSClient client = new FTPSClient())                {                   

client.Connect(ftpUrl,port, new NetworkCredential(userName, password), ESSLSupportMode.CredentialsRequired |                               ESSLSupportMode.DataChannelRequested,  AcceptAllCertifications,   new X509Certificate2(@"C:\Certificates\certificat.crt"),  0, 0, 0, 60, true, EDataConnectionMode.Passive);
 ulong result = client.PutFile(@"C:\Work\TechnicalTraces.txt", "TechnicalTraces" + DateTime.Now.Ticks.ToString() + ".txt");                                      IList<DirectoryListItem> _listItem = client.GetDirectoryList(); 

foreach (DirectoryListItem li in _listItem)                       

Console.WriteLine(li.Name + ' ' + li.CreationTime);                   

Console.ReadLine();               

}  }

catch (Exception ex)            {                log.Error(ex.Message, ex);                Console.WriteLine(ex.Message);                Console.ReadLine();            }

This is the LOG that I get from FTPGetter:

 

=> 200 Command okay

<= NOOP

=> 200 Command okay

<= NOOP

=> 200 Command okay

<= NOOP

=> 200 Command okay

<= NOOP

=> 200 Command okay

<= NOOP

=> 451 Requested action aborted: Remote IP address can not be changed from control to data session

<= PORT 10,3,2,50,51,127

=> 200 Command okay

<= TYPE I

=> 257 "/" is current directory.

<= PWD

[Info] SSL Info:

 REMOVED THE INFORMATION OF THE CERTIFICATE

[Info] SSL Version: TLSv1

=> 502 Command not implemented

<= REST 0

=> 200 Command okay

<= TYPE I

=> 200 Command okay

<= PROT P

=> 200 Command okay

<= PBSZ 0

=> 215 UNIX XFB/Gateway

<= SYST

=> 230 User logged in, proceed

<= PASS *hidden*

=> 331 Send password please

<= USER EVERIALT

=> 234 AUTH command OK, waiting handshake

<= AUTH TLS

=> 220 Welcome to Synchrony Gateway FTP server

Connecting to XXX.XXX.XX.XX:6538

Coordinator
Jan 12, 2012 at 2:45 PM

Hi,

Where do u receive the error? On Connect, PutFile or GetDirectoryList?

Best,

Alessandro

 

Jan 12, 2012 at 2:48 PM

Hi Alex.

Thanks for your answer.

It's on Connect that I have the error.

Best regards

Luis

Jan 12, 2012 at 11:16 PM

After some more testing, I found why I have the error. It's releated to the protocol that the server uses. It's using SSL Explicit, and I'm not able to communicate with TLS.

Any ideas ?

Thanks in advance.

Best regards

 

Luis

Coordinator
Jan 12, 2012 at 11:54 PM

Luis,

this FTPS library employs the .Net stack for SSL/TLS encryption. The configuration you posted uses explicit FTPS on port 21 with a client certificate.

Can you post the full .Net exception stack trace in order to understand where it gets stuck?

 

Best,

Alessandro

 

 

Jan 13, 2012 at 12:02 AM

Hello again Alex.

I enabled the network trace on the .NET Framework, I'll send the stack trace of the .NET Exception and a lit bit of information before the exception.

Sorry for the bad formatting.

Best regards

Luis

 

System.Net.Sockets Verbose: 0 : [9248] Exiting Socket#50934842::Send() -> 95#95System.Net.Sockets Verbose: 0 : [9248] Socket#50934842::Receive()System.Net.Sockets Verbose: 0 : [9248] Data from Socket#50934842::ReceiveSystem.Net.Sockets Verbose: 0 : [9248] 00000000 : 15 03 01 00 02                                  : .....System.Net.Sockets Verbose: 0 : [9248] Exiting Socket#50934842::Receive() -> 5#5System.Net.Sockets Verbose: 0 : [9248] Socket#50934842::Receive()System.Net.Sockets Verbose: 0 : [9248] Data from Socket#50934842::ReceiveSystem.Net.Sockets Verbose: 0 : [9248] 00000005 : 02 28                                           : .(System.Net.Sockets Verbose: 0 : [9248] Exiting Socket#50934842::Receive() -> 2#2System.Net.Sockets Verbose: 0 : [9248] Socket#50934842::Receive()System.Net.Sockets Verbose: 0 : [9248] Data from Socket#50934842::ReceiveSystem.Net.Sockets Verbose: 0 : [9248] 00000007 :                                                 : System.Net.Sockets Verbose: 0 : [9248] Exiting Socket#50934842::Receive() -> 0#0System.Net Error: 0 : [9248] Exception in the #12036987::UnhandledExceptionHandler - Received an unexpected EOF or 0 bytes from the transport stream.System.Net Error: 0 : [9248]    at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)   at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)   at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)   at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)   at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)   at System.Net.Security.SslStream.AuthenticateAsClient(String targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, Boolean checkCertificateRevocation)   at AlexPilotti.FTPS.Client.FTPSClient.CreateSSlStream(Stream s, Boolean leaveInnerStreamOpen)   at AlexPilotti.FTPS.Client.FTPSClient.SwitchCtrlToSSLMode()   at AlexPilotti.FTPS.Client.FTPSClient.AuthCmd(EAuthMechanism authMech)   at AlexPilotti.FTPS.Client.FTPSClient.SslControlChannelCheckExplicitEncryptionRequest(ESSLSupportMode sslSupportMode)   at AlexPilotti.FTPS.Client.FTPSClient.Connect(String hostname, Int32 port, NetworkCredential credential, ESSLSupportMode sslSupportMode, RemoteCertificateValidationCallback userValidateServerCertificate, X509Certificate x509ClientCert, Int32 sslMinKeyExchangeAlgStrength, Int32 sslMinCipherAlgStrength, Int32 sslMinHashAlgStrength, Nullable`1 timeout, Boolean useCtrlEndPointAddressForData, EDataConnectionMode dataConnectionMode)   at TestAlexFTPClient.Program.Connect_ToFtpWithSSLEnabled_ConnectsSuccessfully() in C:\Users\Luis de Sousa\Documents\Visual Studio 2010\Projects\TestAlexFTPClient\TestAlexFTPClient\Program.cs:line 41   at TestAlexFTPClient.Program.Main(String[] args) in C:\Users\Luis de Sousa\Documents\Visual Studio 2010\Projects\TestAlexFTPClient\TestAlexFTPClient\Program.cs:line 16   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)   at System.Threading.ThreadHelper.ThreadStart()

Jan 13, 2012 at 10:33 AM

Hello Alex.

One last information, the server with wich I'm trying to communicate is: "Welcome to Synchrony Gateway FTP server".

Are there any known issues with this server ?

I ask this, because the same code works with: ProFTPD 1.3.3c Server.

Thanks in advance.

Best regards

 

Luis

Coordinator
Jan 13, 2012 at 9:54 PM
Edited Jan 13, 2012 at 9:54 PM

Luis,

from what I see it could be related to the SSL/TLS client side X509 certificate authentication.

Unfortunately it's impossible to help you further w/o replicating a similar working environment.

 

Best,

Alessandro

Jan 14, 2012 at 10:14 PM
alexp wrote:

Luis,

from what I see it could be related to the SSL/TLS client side X509 certificate authentication.

Unfortunately it's impossible to help you further w/o replicating a similar working environment.

 

Best,

Alessandro

Alessandro,

Thanks for your help, I Enabled the log on the .NET FWK and I can see a message releated to the certificates:

System.Net Information: 0 : [2336] SecureChannel#37839230 - Cannot find the certificate in either the LocalMachine store or the CurrentUser store.

I'll need some more time in order to understand why he can't find the certificate, I've installed it in both locations.

 I'll keep you posted.

Best regards

 

Luis

Jul 17, 2012 at 12:15 PM

Good morning,

Sorry if i do not write well in English.

I have this same problem with the following code:

     X509Certificate certificadoCliente = new X509Certificate();
                    certificadoCliente = null;
                    mensaje = "2antesDeConnect.";
                    client.Connect(host, port, new NetworkCredential(user, pwd), ESSLSupportMode.All, delegate { return true; }, certificadoCliente, 0, 0, 0, null);
                    mensaje = "3despuesDeConnect.";
                    //client.Connect(host, new NetworkCredential(user, pwd), ESSLSupportMode.All, delegate { return true; });
                    client.PutFile(localFile, ftpFileName, new FileTransferCallback(onFileTransfer));
                    mensaje = "4despuesDePutFile.";

The error is giving me to make client.connect and FTPeS provider assures me that I need a client certificate. The port is the 990.

If i use a ftp client "FileZilla" connect and copy files correctly.

Thanks