Home Forums .NET libraries Xceed SFTP/FTP for .NET SSL Authentication

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

    I am trying to connect to a remote host via SSL. The connection works fine however, when I try to authenicate via

    FTPClient.Authenticate(SSL, None, Nothing, Private)

    the server tries to talk back to me. In a console app this is fine because the reply is written directly to the console. My problem is that I am trying to do this through a windows service and have nothing to receive the reply from the server. In the sample console application, the connection authenticates and the remote server asks if the certificate is accepatable. How can I simulate this programatically? Thanks in advance for the help.

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

    User (Old forums)
    Member
    Post count: 23064

    Upon further inspection of the documentation I have found the necessary steps. For those who are interested here they are:

    Handle the FTPClient.CertificateReceived Event

    set e.action = VerificationAction.Accept

    That’s it. It’s amazing what a little reading into the documentation will do for you.

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

    User (Old forums)
    Member
    Post count: 23064

    I am using Xceed.Ftp.v5.1; followed the instructions above and registered for the event described and still getting the exception “Message    “The FTP command execution timed-out.”. Any thoughts?

    Here’s my code snippet:

                    client = new FtpClient();
                    client.TraceWriter = Console.Out;
                    client.Connect(hostname);
                    //client.UseRemoteAddress = true;
                    client.CertificateReceived += new CertificateReceivedEventHandler(this.OnCertificateReceived);
                    client.Authenticate(AuthenticationMethod.Ssl, VerificationFlags.None, null, DataChannelProtection.Private);
                    client.Login(ftpUser, ftpPwd);
                    client.ChangeCurrentFolder(ftpFolder);
                    //client.ClearCommandChannel();

                    foreach (FtpItemInfo item in client.GetFolderContents(“*.txt”))
                    {
                        result.Add(item.Name);
                    }

             private void OnCertificateReceived(object sender, CertificateReceivedEventArgs e)
            {
                // The Status argument property tells you if the server certificate was accepted
                // based on the VerificationFlags you provided.
                if (e.Status != VerificationStatus.ValidCertificate)
                {
                    Console.WriteLine(“The server certificate is invalid: {0}”, e.Status.ToString());
                    Console.WriteLine(e.ServerCertificate.ToString());

                    e.Action = VerificationAction.Accept;
                }
                else
                {
                    Console.WriteLine(“Valid certificate received from server.”);
                    // e.Action’s default value is VerificationAction.Accept
                }
            }

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

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