Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

What is required to send out files to a server with WinSCP (.NET assembly) using FTPS (Secure)?

I've been looking at their documentation and am not really clear on certain aspects like TlsHostCertificateFingerprint or TlsClientCertificatePath.

I've been able to send out files via FTP and SFTP with no problem, but this whole thing just eludes me.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
770 views
Welcome To Ask or Share your Answers For Others

1 Answer

If you have a code for FTP, all you need to add to connect to a well-behaved FTPS (FTP over TLS/SSL) server is to set the SessionOptions.FtpSecure:

// Set up session options
SessionOptions sessionOptions = new SessionOptions
{
    Protocol = Protocol.Ftp,
    HostName = "ftp.example.com",
    UserName = "username",
    Password = "password",
    // Enable FTPS in explicit mode, aka FTPES
    FtpSecure = FtpSecure.Explicit,
};

using (Session session = new Session())
{
    // Connect
    session.Open(sessionOptions);

    // Your code
}

The TlsHostCertificateFingerprint is needed only, if your server certificate is not signed by a trusted authority.

The TlsClientCertificatePath is needed only, if your server requires authenticating with a client certificate.


Easiest is to configure your session in WinSCP GUI and have it generate a code template for you. That's actually how I got the above code.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...