net FtpWebRequest是否支持隐式(FTPS)和显式(FTPES)?

时间:2022-04-07 05:38:04

I am being asked to support implicit and explicit FTPS (also known as FTPES). We are currently using the .NET FtpWebRequest. Does the FtpWebRequest support both types of FTPES, and what is the difference?

我被要求支持隐式和显式的FTPS(也称为FTPES)。我们目前正在使用。net FtpWebRequest。FtpWebRequest是否同时支持两种FTPES,有什么区别?

Thanks

谢谢

5 个解决方案

#1


17  

as far as I know the current (.NET 2.0 and 3.5) version of FtpWebRequest supports Explicit SSL only.

就我所知目前的情况。NET 2.0和3.5)版本的FtpWebRequest只支持显式SSL。

Actually, .NET 2.0 does not currently support implicit SSL, only explicit. We will consider adding this for a future release.

实际上,. net 2.0目前不支持隐式SSL,只支持显式SSL。我们将考虑在将来的版本中添加这个。

JonCole - MSFTModerator at MSDN forum post

JonCole - MSFTModerator at MSDN论坛

If you need to use both Implict and Explicit TLS/SSL you have to try one of third-party FTP/SSL components. Following code uses our Rebex FTP/SSL and is taken from the tutorial page.

如果您需要同时使用Implict和显式TLS/SSL,您必须尝试使用第三方FTP/SSL组件。下面的代码使用我们的Rebex FTP/SSL,并取自教程页面。

Explicit TLS/SSL

明确的TLS / SSL

Client connects to FTP server in a usual non-protected way, usually to port 21 was assigned to FTP protocol. When it is desired to protect the connection using SSL, an SSL negotiation is initialized, control connection is secured and all following communication is being protected.

客户端通常以一种不受保护的方式连接到FTP服务器,通常将端口21分配给FTP协议。当需要使用SSL保护连接时,将初始化SSL协商,保护控制连接,并保护所有后续通信。

// Create an instance of the Ftp class. 
Ftp ftp = new Ftp();

// Connect securely using explicit SSL. 
// Use the third argument to specify additional SSL parameters. 
ftp.Connect(hostname, 21, null, FtpSecurity.Explicit);

// Connection is protected now, we can log in safely. 
ftp.Login(username, password);

Explicit protection means that it is possible to secure the connection at any moment. If you don't know whether you will need the protection on not at the connection time, you might want to connect using the ordinary unencrypted FTP protocol and secure the connection later.

显式保护意味着可以随时保护连接。如果您不知道在连接时是否需要保护,您可能希望使用普通的未加密的FTP协议连接,并在以后确保连接。

Ftp ftp = new Ftp();

// Connect to the server with no protection. 
ftp.Connect(hostname, 21);

// Upgrade connection to SSL. 
// This method also accepts an argument to specify SSL parameters. 
ftp.Secure();

// Connection is protected now, we can log in safely. 
ftp.Login(username, password);

Implicit SSL protection of the FTP session

隐式SSL保护的FTP会话。

FTPS protocol was originally assigned a separate port by the IANA. Upon connection to this port, an SSL negotiation starts immediately and the control connection is secured. All data connections are also secured implicitly in the same way. This is similar to the approach used by HTTPS.

FTPS协议最初由IANA分配一个单独的端口。当连接到这个端口时,立即启动SSL协商,并确保控制连接。所有数据连接也以相同的方式隐式地保护。这类似于HTTPS使用的方法。

This approach is not favored by the IETF and is deprecated. It is supported by Rebex FTP/SSL for interoperability with older servers, but it is strongly recommended to use the explicit protection instead whenever possible.

这种方法不受IETF的支持,并被弃用。Rebex FTP/SSL支持它以实现与旧服务器的互操作性,但强烈建议尽可能使用显式保护。

Ftp ftp = new Ftp();

// Connect securely using implicit SSL. 
// Use the third argument to specify additional SSL parameters. 
ftp.Connect(hostname, 990, null, FtpSecurity.Implicit);

// Connection is protected now, we can log in safely. 
ftp.Login(username, password);

You may download the component at rebex.net/ftp-ssl.net/

您可以在rebex.net/ftp-ssl.net/上下载该组件。

#2


12  

I have used Alex FTPS Client earlier. May be you should look to http://ftps.codeplex.com/.

我之前用过Alex FTPS客户端。也许你应该看看http://ftps.codeplex.com/。

#3


2  

.NET Framework/FtpWebRequest supports only explicit TLS/SSL encryption. It does not support implicit TLS/SSL encryption.

. net Framework/FtpWebRequest只支持显式的TLS/SSL加密。它不支持隐式TLS/SSL加密。

I believe it's unlikely it ever will. The FTP implementation of .NET frameworks uses only standardized features of the protocol. The implicit TLS/SSL encryption was never standardized. It was introduced only as a temporary mechanism to allow using seamless encryption with FTP clients that did not support encryption. In general, there's no reason to use implicit TLS/SSL encryption. An FTP server that supports implicit TLS/SSL encryption only, is broken, imo.

我相信这是不可能的。. net框架的FTP实现只使用协议的标准化特性。隐式TLS/SSL加密从未标准化。它只是作为一种临时机制引入,以允许对不支持加密的FTP客户端使用无缝加密。一般来说,没有理由使用隐式TLS/SSL加密。在我看来,一个只支持隐式TLS/SSL加密的FTP服务器被破坏了。


Anyway, if you need to use the implicit TLS/SSL encryption, you have to use a 3rd party FTP library.

无论如何,如果需要使用隐式TLS/SSL加密,则必须使用第三方FTP库。

With WinSCP .NET assembly, it's easy:

使用WinSCP .NET程序集,很容易:

// Set up session options
SessionOptions sessionOptions = new SessionOptions
{
    Protocol = Protocol.Ftp,
    UserName = "username",
    Password = "password",
    FtpSecure = FtpSecure.Implicit,
};

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

    // Your code
}

You can have WinSCP GUI generate a C# FTP code template, like the one above, for you.

您可以让WinSCP GUI为您生成c# FTP代码模板,如上面所示。

(I'm the author of WinSCP)

(我是WinSCP的作者)

#4


1  

You can also try Ftp.dll FTP/FTPS client.

您也可以尝试Ftp。dll FTP / FTP客户端。

It supports implicit and explicit SSL connections. Here's the implicit sample:

它支持隐式和显式SSL连接。这是隐含的示例:

using(Ftp ftp = new Ftp())
{
    ftp.ConnectSSL("ftp.server.com");

    ftp.Login("user", "password");

    ftp.ChangeFolder("uploads");
    ftp.UploadFile("report.txt", @"c:\report.txt");

    ftp.Close();
}

Please note that this is commercial product and I'm the author of this component.

请注意这是商业产品,我是这个组件的作者。

#5


-1  

edtFTPnet/PRO is an FTP client library that also supports FTPS implicit and explicit modes. It's simply a matter of specifying the right protocol:

edtFTPnet/PRO是一个FTP客户端库,它也支持FTPS内隐和显式模式。这只是指定正确的协议的问题:

 SecureFTPConnection conn = new SecureFTPConnection();
 conn.Protocol = FileTransferProtocol.FTPSImplicit;

 // set remote host, user, pwd etc ...

 // now connect
 conn.Connect();

The same component supports SFTP also.

同样的组件也支持SFTP。

And yes, I am one of the developers of this component (and of edtFTPnet, the free, open source .NET FTP client).

是的,我是这个组件的开发人员之一(edtFTPnet,免费的,开放源码的。net FTP客户端)。

#1


17  

as far as I know the current (.NET 2.0 and 3.5) version of FtpWebRequest supports Explicit SSL only.

就我所知目前的情况。NET 2.0和3.5)版本的FtpWebRequest只支持显式SSL。

Actually, .NET 2.0 does not currently support implicit SSL, only explicit. We will consider adding this for a future release.

实际上,. net 2.0目前不支持隐式SSL,只支持显式SSL。我们将考虑在将来的版本中添加这个。

JonCole - MSFTModerator at MSDN forum post

JonCole - MSFTModerator at MSDN论坛

If you need to use both Implict and Explicit TLS/SSL you have to try one of third-party FTP/SSL components. Following code uses our Rebex FTP/SSL and is taken from the tutorial page.

如果您需要同时使用Implict和显式TLS/SSL,您必须尝试使用第三方FTP/SSL组件。下面的代码使用我们的Rebex FTP/SSL,并取自教程页面。

Explicit TLS/SSL

明确的TLS / SSL

Client connects to FTP server in a usual non-protected way, usually to port 21 was assigned to FTP protocol. When it is desired to protect the connection using SSL, an SSL negotiation is initialized, control connection is secured and all following communication is being protected.

客户端通常以一种不受保护的方式连接到FTP服务器,通常将端口21分配给FTP协议。当需要使用SSL保护连接时,将初始化SSL协商,保护控制连接,并保护所有后续通信。

// Create an instance of the Ftp class. 
Ftp ftp = new Ftp();

// Connect securely using explicit SSL. 
// Use the third argument to specify additional SSL parameters. 
ftp.Connect(hostname, 21, null, FtpSecurity.Explicit);

// Connection is protected now, we can log in safely. 
ftp.Login(username, password);

Explicit protection means that it is possible to secure the connection at any moment. If you don't know whether you will need the protection on not at the connection time, you might want to connect using the ordinary unencrypted FTP protocol and secure the connection later.

显式保护意味着可以随时保护连接。如果您不知道在连接时是否需要保护,您可能希望使用普通的未加密的FTP协议连接,并在以后确保连接。

Ftp ftp = new Ftp();

// Connect to the server with no protection. 
ftp.Connect(hostname, 21);

// Upgrade connection to SSL. 
// This method also accepts an argument to specify SSL parameters. 
ftp.Secure();

// Connection is protected now, we can log in safely. 
ftp.Login(username, password);

Implicit SSL protection of the FTP session

隐式SSL保护的FTP会话。

FTPS protocol was originally assigned a separate port by the IANA. Upon connection to this port, an SSL negotiation starts immediately and the control connection is secured. All data connections are also secured implicitly in the same way. This is similar to the approach used by HTTPS.

FTPS协议最初由IANA分配一个单独的端口。当连接到这个端口时,立即启动SSL协商,并确保控制连接。所有数据连接也以相同的方式隐式地保护。这类似于HTTPS使用的方法。

This approach is not favored by the IETF and is deprecated. It is supported by Rebex FTP/SSL for interoperability with older servers, but it is strongly recommended to use the explicit protection instead whenever possible.

这种方法不受IETF的支持,并被弃用。Rebex FTP/SSL支持它以实现与旧服务器的互操作性,但强烈建议尽可能使用显式保护。

Ftp ftp = new Ftp();

// Connect securely using implicit SSL. 
// Use the third argument to specify additional SSL parameters. 
ftp.Connect(hostname, 990, null, FtpSecurity.Implicit);

// Connection is protected now, we can log in safely. 
ftp.Login(username, password);

You may download the component at rebex.net/ftp-ssl.net/

您可以在rebex.net/ftp-ssl.net/上下载该组件。

#2


12  

I have used Alex FTPS Client earlier. May be you should look to http://ftps.codeplex.com/.

我之前用过Alex FTPS客户端。也许你应该看看http://ftps.codeplex.com/。

#3


2  

.NET Framework/FtpWebRequest supports only explicit TLS/SSL encryption. It does not support implicit TLS/SSL encryption.

. net Framework/FtpWebRequest只支持显式的TLS/SSL加密。它不支持隐式TLS/SSL加密。

I believe it's unlikely it ever will. The FTP implementation of .NET frameworks uses only standardized features of the protocol. The implicit TLS/SSL encryption was never standardized. It was introduced only as a temporary mechanism to allow using seamless encryption with FTP clients that did not support encryption. In general, there's no reason to use implicit TLS/SSL encryption. An FTP server that supports implicit TLS/SSL encryption only, is broken, imo.

我相信这是不可能的。. net框架的FTP实现只使用协议的标准化特性。隐式TLS/SSL加密从未标准化。它只是作为一种临时机制引入,以允许对不支持加密的FTP客户端使用无缝加密。一般来说,没有理由使用隐式TLS/SSL加密。在我看来,一个只支持隐式TLS/SSL加密的FTP服务器被破坏了。


Anyway, if you need to use the implicit TLS/SSL encryption, you have to use a 3rd party FTP library.

无论如何,如果需要使用隐式TLS/SSL加密,则必须使用第三方FTP库。

With WinSCP .NET assembly, it's easy:

使用WinSCP .NET程序集,很容易:

// Set up session options
SessionOptions sessionOptions = new SessionOptions
{
    Protocol = Protocol.Ftp,
    UserName = "username",
    Password = "password",
    FtpSecure = FtpSecure.Implicit,
};

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

    // Your code
}

You can have WinSCP GUI generate a C# FTP code template, like the one above, for you.

您可以让WinSCP GUI为您生成c# FTP代码模板,如上面所示。

(I'm the author of WinSCP)

(我是WinSCP的作者)

#4


1  

You can also try Ftp.dll FTP/FTPS client.

您也可以尝试Ftp。dll FTP / FTP客户端。

It supports implicit and explicit SSL connections. Here's the implicit sample:

它支持隐式和显式SSL连接。这是隐含的示例:

using(Ftp ftp = new Ftp())
{
    ftp.ConnectSSL("ftp.server.com");

    ftp.Login("user", "password");

    ftp.ChangeFolder("uploads");
    ftp.UploadFile("report.txt", @"c:\report.txt");

    ftp.Close();
}

Please note that this is commercial product and I'm the author of this component.

请注意这是商业产品,我是这个组件的作者。

#5


-1  

edtFTPnet/PRO is an FTP client library that also supports FTPS implicit and explicit modes. It's simply a matter of specifying the right protocol:

edtFTPnet/PRO是一个FTP客户端库,它也支持FTPS内隐和显式模式。这只是指定正确的协议的问题:

 SecureFTPConnection conn = new SecureFTPConnection();
 conn.Protocol = FileTransferProtocol.FTPSImplicit;

 // set remote host, user, pwd etc ...

 // now connect
 conn.Connect();

The same component supports SFTP also.

同样的组件也支持SFTP。

And yes, I am one of the developers of this component (and of edtFTPnet, the free, open source .NET FTP client).

是的,我是这个组件的开发人员之一(edtFTPnet,免费的,开放源码的。net FTP客户端)。