Home Forums .NET libraries Xceed SFTP/FTP for .NET Secure Connection FtpSslException

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #21364 |

    Hi,

    We are using Xceed FTP for long time. It was working fine until the last week. We updated our XCeed FTP  to latest Xceed http://FTP.v5.1 version after that it does not connect to secure ftp’s. Even on CertificateReceived handler we accept the e.Action = VerificationAction.Accept; if it is invalid certificate.

    Is there any changed on newer version? i don’t see any changes on documentation also.

    here the sample code for you..

     

    fc = new Xceed.Ftp.FtpClient(); 

    fc.CertificateReceived += new CertificateReceivedEventHandler(fc_CertificateReceived);

                    fc.CommandSent += new CommandSentEventHandler(fc_CommandSent);

                    fc.ReplyReceived += new ReplyReceivedEventHandler(fc_ReplyReceived);

                    fc.StateChanged += new EventHandler(fc_StateChanged);

                    fc.FileTransferStatus += new FileTransferStatusEventHandler(fc_FileTransferStatus);

                    fc.ParsingListingLine += new ParsingListingLineEventHandler(fc_ParsingListingLine);

                    fc.RepresentationType = RepresentationType.Ascii;

                    int ftpPortNo = string.IsNullOrEmpty(portno.Trim()) ? 0 : int.Parse(portno.Trim());

                    //implicit secure ftp default port no #990

                    if (IsSecured && ftpPortNo == 0) ftpPortNo = 990;

                    //implicit ftp default port no #21

                    if (!IsSecured && ftpPortNo == 0) ftpPortNo = 21;

                    FTPLog(string.Format(“Trying to connect with ftpaddress:{0}, portno#{1}…”,ftpaddr,ftpPortNo));

                    if (IsSecured)

                        fc.Connect(ftpaddr, ftpPortNo,AuthenticationMethod.Tls,VerificationFlags.None,null);

                    else

                        fc.Connect(ftpaddr, ftpPortNo); 

     

    and the certificatereceived handler

    private void fc_CertificateReceived(object sender, CertificateReceivedEventArgs e)

            {

                

                if (e.Status != VerificationStatus.ValidCertificate)

                {

                    e.Action = VerificationAction.Accept;

                }

            } 

     

    After the latest version of Xceed FTP it broken live now. Need a thought to fix it.

    here is the error..

    Message: FTP State Changed: Connecting

    Message: FTP State Changed: NotConnected

    Message: Xceed.Ftp.FtpException: A Xceed.Ftp.FtpSslException occurred while receiving a reply. Please see and report the value of the InnerException property, which contains the actual exception and stack trace. —> Xceed.Ftp.FtpSslException: SslStream authentication failed. Possible causes: 1) The server requires a certificate in order to connect and none was provided. 2) The certificate provided was rejected by the .NET framework/Windows (usually because it doesn’t contain a private key). 3) The certificate provided was rejected by the server. —> System.ArgumentException: The verification status is invalid.

    Parameter name: status

       at Xceed.Ftp.CertificateReceivedEventArgs..ctor(Certificate certificate, VerificationFlags flags, VerificationStatus status)

       at Xceed.Ftp.Engine.FtpCommandChannel.OnServerCertificateValidationCallback(Object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)

       at System.Net.Security.SecureChannel.VerifyRemoteCertificate(RemoteCertValidationCallback remoteCertValidationCallback)

       at System.Net.Security.SslState.CompleteHandshake()

       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.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)

       at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)

       at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)

       at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)

       at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)

       at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)

       at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)

       at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)

       at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)

       at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)

       at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)

       at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)

       at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)

       at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, 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 Xceed.Ftp.Engine.FtpCommandChannel.get_CommandChannelStream()

       — End of inner exception stack trace —

       at Xceed.Ftp.Engine.FtpCommandChannel.get_CommandChannelStream()

       at Xceed.Ftp.Engine.FtpCommandChannel.ReceiveReplyOperation.ReadOperationCompleted(IAsyncResult asyncResult)

       — End of inner exception stack trace —

       at Xceed.Ftp.Engine.ConnectFtpCommand.Execute(FtpCommandChannel commandChannel)

       at Xceed.Ftp.Engine.BaseFtpCommand.BackgroundWorker_DoWork(Object sender, DoWorkEventArgs e)

       at Xceed.Ftp.Engine.ConnectFtpCommand.EndExecute(IAsyncResult asyncResult)

       at Xceed.Ftp.FtpClient.Connect(String hostName, Int32 port, AuthenticationMethod authenticationMethod, VerificationFlags verificationFlags, Certificate clientCertificate)

       at SnapShotExtract.AllExtractsFTP.FTPFile(ArrayList filelist, String ftpaddr, String usrname, String pwd, String portno, Boolean IsSecured) in C:\CentrisSourceRepository\Dev\Source\ObjectSolutions\Source\SnapShotExtract\AllExtractsFTP.cs:line 514

     

    Thanks,

    Raj 

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Rajkumar (had 1128 views)

    Diane [Xceed]
    Moderator
    Post count: 1353

    (this was answered by email, but I am also posting it here to benefit other forum members)

    Hi Rajkumar,

    After verification with the developer, this is a bug that has been fixed. However, a mistake on our end caused it not to be released in version 5.1. This has been remedied.

    You can get a build with the fix here:
      http://xceed.com/CS/forums/thread/26565.aspx

    The VerificationStatus enumeration is now a bit field. As such, in your CertificateReceived event handler your code should now be:

       if( ( e.Status & VerificationStatus.ValidCertificate ) == 0 )
       {
          e.Action = VerificationAction.Accept;
       }

     

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Diane [Xceed] (had 147 views)

    User (Old forums)
    Member
    Post count: 23064

    Thank you. I was also suppose to post it here for other users. Good you replied here too.

    Thanks,

    Raj 

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Rajkumar (had 882 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.