Connect to FTPS with proxy in C#

别等时光非礼了梦想. 提交于 2019-11-29 07:52:42

.NET framework indeed does not support TLS/SSL connections over proxy.

You have to use a 3rd party FTP library.

Also note that your code is not using "implicit" FTPS. It's using "explicit" FTPS. Implicit FTPS is not supported by .NET framework either.


For example with WinSCP .NET assembly, you can use:

// Setup session options
SessionOptions sessionOptions = new SessionOptions
{
    Protocol = Protocol.Ftp,
    HostName = "example.com",
    UserName = "user",
    Password = "mypassword",
    FtpSecure = FtpSecure.Explicit, // Or .Implicit
};

// Configure proxy
sessionOptions.AddRawSettings("ProxyMethod", "3");
sessionOptions.AddRawSettings("ProxyHost", "proxy");

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

    var listing = session.ListDirectory(path);
}

For the options for SessionOptions.AddRawSettings, see raw settings.

(I'm the author of WinSCP)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!