"Authentication failed because the remote party has closed the transport stream" 使用 FluentFTP 在 TLS/SSL 上传输 to/from FTP 服务器时
"Authentication failed because the remote party has closed the transport stream" when transferring to/from FTP server over TLS/SSL using FluentFTP
我在我的项目中使用 FluentFTP
lib 通过 TLS 与 FTP 一起工作,但这里有些麻烦。
此代码工作正常:
using (var conn = new FtpClient("adress", "user", "password"))
{
conn.EncryptionMode = FtpEncryptionMode.Explicit;
conn.ValidateAnyCertificate = true;
conn.Connect();
conn.CreateDirectory("/test/path/that/should/be/created", true);
}
目录已创建。但在其他示例中,它效果不佳。
第一个例子(日志文件 - https://pastebin.com/jNyZ3fmD):
public static void DownloadFile()
{
using (var conn = new FtpClient("adress", "user", "password"))
{
conn.EncryptionMode = FtpEncryptionMode.Explicit;
conn.ValidateAnyCertificate = true;
conn.Connect();
conn.DownloadFile("localPath", "ftpPath", FtpLocalExists.Overwrite, FtpVerify.Retry);
}
}
我有错误:
"Error while uploading the file to the server. See InnerException for
more info."
IOException: Authentication failed because the remote
party has closed the transport stream
正在尝试使用下面的代码从 FTP 获取 file/dir-list return 控制台中没有任何内容(日志文件 - https://pastebin.com/V8AiLs8k):
using (var conn = new FtpClient("adress", "user", "password"))
{
//conn.Connect();
conn.EncryptionMode = FtpEncryptionMode.Explicit;
conn.ValidateCertificate += new FtpSslValidation(OnValidateCertificate);
conn.Connect();
// get a recursive listing of the files & folders in a specific folder
foreach (var item in conn.GetListing())
{
switch (item.Type)
{
case FtpFileSystemObjectType.Directory:
Console.WriteLine("Directory! " + item.FullName);
Console.WriteLine("Modified date: " + conn.GetModifiedTime(item.FullName));
break;
case FtpFileSystemObjectType.File:
Console.WriteLine("File! " + item.FullName);
Console.WriteLine("File size: " + conn.GetFileSize(item.FullName));
Console.WriteLine("Modified date: " + conn.GetModifiedTime(item.FullName));
Console.WriteLine("Chmod: " + conn.GetChmod(item.FullName));
break;
case FtpFileSystemObjectType.Link:
break;
}
Console.WriteLine(item);
}
}
用户拥有下载、创建和删除文件的权限。但是我只能在服务器上创建一个目录。
这似乎是由于 Fluen 中缺少 TLS 会话恢复支持FTP:
https://github.com/robinrodricks/FluentFTP/issues/347
如果您与服务器所有者确认,您将不得不切换到另一个 FTP 库。
对于类似的问题(对于隐式 TLS,而您使用的是显式 TLS),请参阅:
或者要求所有者关闭会话恢复要求(尽管从安全角度来看这很糟糕)。
有关该问题的更多参考资料,另请参阅 。
我在我的项目中使用 FluentFTP
lib 通过 TLS 与 FTP 一起工作,但这里有些麻烦。
此代码工作正常:
using (var conn = new FtpClient("adress", "user", "password"))
{
conn.EncryptionMode = FtpEncryptionMode.Explicit;
conn.ValidateAnyCertificate = true;
conn.Connect();
conn.CreateDirectory("/test/path/that/should/be/created", true);
}
目录已创建。但在其他示例中,它效果不佳。
第一个例子(日志文件 - https://pastebin.com/jNyZ3fmD):
public static void DownloadFile()
{
using (var conn = new FtpClient("adress", "user", "password"))
{
conn.EncryptionMode = FtpEncryptionMode.Explicit;
conn.ValidateAnyCertificate = true;
conn.Connect();
conn.DownloadFile("localPath", "ftpPath", FtpLocalExists.Overwrite, FtpVerify.Retry);
}
}
我有错误:
"Error while uploading the file to the server. See InnerException for more info." IOException: Authentication failed because the remote party has closed the transport stream
正在尝试使用下面的代码从 FTP 获取 file/dir-list return 控制台中没有任何内容(日志文件 - https://pastebin.com/V8AiLs8k):
using (var conn = new FtpClient("adress", "user", "password"))
{
//conn.Connect();
conn.EncryptionMode = FtpEncryptionMode.Explicit;
conn.ValidateCertificate += new FtpSslValidation(OnValidateCertificate);
conn.Connect();
// get a recursive listing of the files & folders in a specific folder
foreach (var item in conn.GetListing())
{
switch (item.Type)
{
case FtpFileSystemObjectType.Directory:
Console.WriteLine("Directory! " + item.FullName);
Console.WriteLine("Modified date: " + conn.GetModifiedTime(item.FullName));
break;
case FtpFileSystemObjectType.File:
Console.WriteLine("File! " + item.FullName);
Console.WriteLine("File size: " + conn.GetFileSize(item.FullName));
Console.WriteLine("Modified date: " + conn.GetModifiedTime(item.FullName));
Console.WriteLine("Chmod: " + conn.GetChmod(item.FullName));
break;
case FtpFileSystemObjectType.Link:
break;
}
Console.WriteLine(item);
}
}
用户拥有下载、创建和删除文件的权限。但是我只能在服务器上创建一个目录。
这似乎是由于 Fluen 中缺少 TLS 会话恢复支持FTP:
https://github.com/robinrodricks/FluentFTP/issues/347
如果您与服务器所有者确认,您将不得不切换到另一个 FTP 库。
对于类似的问题(对于隐式 TLS,而您使用的是显式 TLS),请参阅:
或者要求所有者关闭会话恢复要求(尽管从安全角度来看这很糟糕)。
有关该问题的更多参考资料,另请参阅