Imports Limilabs.FTP.Client
Imports System.Net.Security

Module Module1

    Sub Main()
        Using client As New Ftp()
            ' Use this line to validate self-signed certificates:
            AddHandler client.ServerCertificateValidate, AddressOf ValidateCerificate

            client.ConnectSSL("ftp.example.org")
            client.Login("username", "password")

            For Each item As FtpItem In client.GetList()
                If item.IsFolder = True Then
                    Console.WriteLine("[{0}]", item.Name)
                Else
                    Console.WriteLine("{0}", item.Name)
                End If
            Next
            client.Close()
        End Using
        Console.ReadKey()
    End Sub

    Private Sub ValidateCerificate(ByVal sender As Object, ByVal e As ServerCertificateValidateEventArgs)
        Const ignoredErrors As SslPolicyErrors = _
            SslPolicyErrors.RemoteCertificateChainErrors Or _
            SslPolicyErrors.RemoteCertificateNameMismatch

        If (e.SslPolicyErrors And ignoredErrors) <> 0 Then
            e.IsValid = True
            Return
        End If
        e.IsValid = False
    End Sub

End Module
