VB.NET Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

VB.NET Examples

Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
FTP
HTML Conversion
HTTP
IMAP
Encryption
MHT / HTML Email
POP3
PFX
RSA
S/MIME
SMTP
Socket
Spider
SSH
SSH Tunnel
SSH Key
SFTP
Tar Archive
Upload
XML
XMP
Zip Compression
Misc

More Examples...
Amazon S3
Email Object
DKIM / DomainKey
NTLM
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
Bzip2
LZW

Byte Array
VB.NET FTPS
System.IO

 

 

 

 

 

 

Secure FTP (FTPS) using AUTH TLS

Download: Chilkat .NET Assemblies

VB.NET example program showing how to do secure FTP upload and download (FTPS).

    ' Secure FTP (FTPS) using AUTH TLS
    '
    ' What is TLS?
    ' Transport Layer Security (TLS) is the successor to 
    ' Secure Sockets Layer (SSL). It is a cryptographic protocol that 
    ' provides secure communications on the Internet for such things as 
    ' email, FTP, and other data transfers. There are slight differences 
    ' between SSL 3.0 and TLS 1.0, but the protocols are substantially the 
    ' same.
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        ' The most common method of doing secure FTP file transfers is
        ' by AUTH TLS (also known as AUTH SSL).
        ' The client connects on the standard unencrypted FTP port 21
        ' and then issues an "AUTH TLS" command to convert the TCP/IP channel
        ' to a TLS encrypted channel.  All communications from that point onward,
        ' including data transfers, are encrypted.

        ' This VB.NET FTPS example shows to how do secure FTP uploads and 
        ' downloads using AUTH TLS.

        Dim ftp As New Chilkat.Ftp2
        Dim success As Boolean

        success = ftp.UnlockComponent("Anything for 30-day trial")
        If (Not success) Then
            MessageBox.Show(ftp.LastErrorText)
            Exit Sub
        End If

        ' Set the AuthTls property = true.
        ftp.AuthTls = True

        ' Leave the Ssl property false.  The Ssl property is used
        ' for doing Secure FTP over SSL on port 990 (implicit SSL)
        ' FTP Implicit SSL is covered in another example.
        ftp.Ssl = False

        ' Set the FTP hostname, login, and password.
        ftp.Hostname = "ftp.yourftpserver.com"
        ftp.Username = "***"
        ftp.Password = "****"


        ' Session logging is not required, but I'm turning it on here to see
        ' what transpires during the FTP session.  The session log provides the
        ' unencrypted FTP requests and responses.
        ftp.KeepSessionLog = True

        ' Connect and login to the FTP server.  This establishs a control connection
        ' to the FTP server (port 21), converts the channel to TLS (because AuthTls is true),
        ' and then authenticates.
        success = ftp.Connect()
        If (Not success) Then
            MessageBox.Show(ftp.LastErrorText)
            Exit Sub
        End If

        ' You may need to clear the control channel if your FTP client
        ' is located behind a network-address-translating router
        ' such as with a Cable/DSL router.
        'ftp.ClearControlChannel()

        ' Upload a file.
        Dim localFilename As String
        Dim remoteFilename As String
        localFilename = "hamlet.xml"
        remoteFilename = "hamlet.xml"

        ' Note: if PutFile fails and you get this in your LastErrorText:
        ' PortReply: 530 Only client IP address allowed for PORT command.
        ' It indicates that you must first clear the control channel
        ' because your FTP client sits behind a router doing NAT (network 
        ' address translation).  The router is not able to translate the 
        ' IP address in the PORT command if the control channel is encrypted.
        success = ftp.PutFile(localFilename, remoteFilename)
        If (Not success) Then
            MessageBox.Show(ftp.LastErrorText)
            Exit Sub
        End If

        ' You may examine the LastErrorText even when successful
        ' to review the details of the file transfer.  You can verify
        ' that the file was transferred over a secure channel:
        MessageBox.Show(ftp.LastErrorText)

        ' Download a file.
        localFilename = "hamletDownloaded.xml"

        success = ftp.GetFile(remoteFilename, localFilename)
        If (Not success) Then
            MessageBox.Show(ftp.LastErrorText)
            Exit Sub
        End If

        ' Disconnect
        ftp.Disconnect()

        ' Display the session log
        TextBox1.Text = ftp.SessionLog


    End Sub




This program produces the following session log:


220 Welcome to Akron Archives Backup Server - Authorized Accounts Only
.
AUTH TLS
234 AUTH command OK. Initializing SSL connection.
.
PBSZ 0
200 PBSZ command OK. Protection buffer size set to 0.
.
PROT P
200 PROT command OK. Using private data connection.
.
USER web0041
331 User name okay, need password.
.
PASS ****
230 User logged in, proceed.
.
TYPE I
200 Type set to I.
.
CCC
200 Command channel switched to clear-text.
.
PORT 192,168,1,100,4,150
200 PORT Command successful.
.
STOR hamlet.xml
150 Opening BINARY mode data connection for hamlet.xml.
226-Maximum disk quota limited to 512000 kBytes
    Used disk quota 218923 kBytes, available 293076 kBytes
226 Transfer complete.
.
PORT 192,168,1,100,4,152
200 PORT Command successful.
.
RETR hamlet.xml
150 Opening BINARY mode data connection for hamlet.xml (279658 Bytes).
226-Maximum disk quota limited to 512000 kBytes
    Used disk quota 218923 kBytes, available 293076 kBytes
226 Transfer complete.
.
QUIT
221 Goodbye!
 

© 2000-2012 Chilkat Software, Inc. All Rights Reserved.

Mail Component · XML Parser