首页 > 解决方案 > 使用 Ubuntu 的 FluentFTP 连接到 FTP 服务器时出现问题

问题描述

我正在使用此代码尝试建立与 Windows FTP 服务的 FTP 连接

FtpClient client = new FtpClient(ip, user, password);
client.ConnectTimeout = 600000;
client.ReadTimeout = 60000;
client.EncryptionMode = FtpEncryptionMode.Implicit;
client.SslProtocols = System.Security.Authentication.SslProtocols.Tls;
client.DataConnectionType = FluentFTP.FtpDataConnectionType.PASV;
client.ValidateAnyCertificate = true;

client.Connect();

在 Windows 机器中,连接已正确建立,但在我的 Ubuntu 机器上无法建立连接,我总是收到错误消息

"error:141E70BF:SSL routines:tls_construct_client_hello:no protocols available"

我怎样才能使这项工作?

==============更新

我尝试了 FTPClient 的 AutoDetect 方法,但该方法没有检索到任何配置文件

AutoConnect 方法似乎也可以连接,但是当我尝试获取文件夹列表时,会出现配置文件需要 SSL 的错误

当我为客户端启用跟踪时,我在日志中得到以下输出:

# Connect()
Status:   Connecting to server:21
Response: 220-Microsoft FTP Service
Response: 220 ************************************************************
Status:   Detected FTP server: WindowsServerIIS
Command:  AUTH TLS
Response: 234 AUTH command ok. Expecting TLS Negotiation.
Status:   Disposing FtpSocketStream...
Error:    FTPS Authentication Failed
                                    

标签: ubuntu.net-corefluentftp

解决方案


我只是想出了如何按照这篇文章的说明进行这项工作:

OpenSSL v1.1.1 Ubuntu 20 TLSv1 - 没有可用的协议

还有这个

https://askubuntu.com/questions/1233186/ubuntu-20-04-how-to-set-lower-ssl-security-level

就我而言,我的目标服务器似乎很旧,nmap 输出是这样的:

21/tcp open  ftp
| ssl-enum-ciphers: 
|   SSLv3: 
|     ciphers: 
|       TLS_RSA_WITH_3DES_EDE_CBC_SHA (rsa 2048) - C
|       TLS_RSA_WITH_RC4_128_SHA (rsa 2048) - C
|       TLS_RSA_WITH_RC4_128_MD5 (rsa 2048) - C
|     compressors: 
|       NULL
|     cipher preference: server
|   TLSv1.0: 
|     ciphers: 
|       TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (secp256r1) - A
|       TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA (secp256r1) - A
|       TLS_RSA_WITH_AES_256_CBC_SHA (rsa 2048) - A
|       TLS_RSA_WITH_AES_128_CBC_SHA (rsa 2048) - A
|       TLS_RSA_WITH_3DES_EDE_CBC_SHA (rsa 2048) - C
|       TLS_RSA_WITH_RC4_128_SHA (rsa 2048) - C
|       TLS_RSA_WITH_RC4_128_MD5 (rsa 2048) - C
|     compressors: 
|       NULL
|     cipher preference: server
|     warnings: 
|       64-bit block cipher 3DES vulnerable to SWEET32 attack
|       Broken cipher RC4 is deprecated by RFC 7465
|       Ciphersuite uses MD5 for message integrity
|       Weak certificate signature: SHA1
|_  least strength: C 

我必须配置 openssl 以使用现在几乎不推荐使用的 TLSv1


推荐阅读