我的应用程序以 .NET 4.6.1 为目标,我尝试使用 FtpWebRequest
使用 TLS 连接到 FileZilla 服务器。
但是,当启用选项 TLS session 恢复时,下面的代码失败了
450 TLS session of data connection has not resumed or the session does not match the control connection
如果我禁用该选项,则代码有效。
令人惊讶的是,在我们需要重新启动服务器进行更新之前,代码一直有效!
我们尝试使用 PHP 使用 SSL 代码,并且在启用该选项时它也可以正常工作。
System.Net.ServicePointManager.ServerCertificateValidationCallback =
New System.Net.Security.RemoteCertificateValidationCallback(
AddressOf myCertificateValidation)
' Set up the request
Dim ftpRequest As System.Net.FtpWebRequest =
CType(System.Net.WebRequest.Create("ftp://myserver.mydomain.eu"),
System.Net.FtpWebRequest)
ftpRequest.EnableSsl = True
ftpRequest.KeepAlive = False
ftpRequest.UsePassive = False
' use the provided credentials
ftpRequest.Credentials = New System.Net.NetworkCredential("MyUser", "MyPwd")
' List the directory content
ftpRequest.Method = System.Net.WebRequestMethods.Ftp.ListDirectoryDetails
' Send the request
Dim ftpResponse As System.Net.FtpWebResponse =
CType(ftpRequest.GetResponse, System.Net.FtpWebResponse)
我尝试设置几个参数,但结果始终相同。
最佳答案
我终于找到了问题。您必须在下面的代码中将 ftpRequest.KeepAlive 更改为 true,它才能完成这项工作。
在找到好的参数之前,我检查了很多参数的配置...
希望这有帮助。
艾蒂安。
关于.net - 启用 "Require TLS session resumption on data connection when using PROT P"的 FileZilla 服务器上基于 SSL/TLS 的 FtpWebRequest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58506578/