当我尝试连接到我的 FTP 服务器以使用 FluentFTP 上传文件时,我得到以下信息:
根据验证程序,远程证书无效。
然而 FileZilla 工作正常,没有错误或警告。
我做错了什么,如果它实际上是服务器的问题,我怎么能忽略这个错误
这是我的代码:
var credentials = new NetworkCredential(Username, Password);
FtpClient client = new FtpClient(Host, credentials)
{
Port = Port,
EncryptionMode = FtpEncryptionMode.Explicit
};
client.DataConnectionEncryption = true;
client.Connect();
var result = client.UploadFileAsync(FilePathName, RemotePathName, AllowOverwrite ? FtpExists.Overwrite : FtpExists.Skip, CreateRemoteDirectory, token).GetAwaiter().GetResult();
client.Disconnect();
我也尝试添加事件client.ValidateCertificate += Client_ValidateCertificate;
private static void Client_ValidateCertificate(FtpClient control, FtpSslValidationEventArgs e)
{
e.PolicyErrors = SslPolicyErrors.None;
}
但我无法让它工作,我仍然得到同样的错误。
这是 FileZilla 的输出:
Status: Selected port usually in use by a different protocol.
Status: Resolving address of xxxxxxxxxxxxxxxxxxxxxx
Status: Connecting to xxx.xxx.xxx.xxx:xx...
Status: Connection established, waiting for welcome message...
Status: Initializing TLS...
Status: Verifying certificate...
Status: TLS connection established.
Status: Logged in
Status: Retrieving directory listing of "xxxxxxxxxxxxx"...
Status: Directory listing of "xxxxxxxxxxxxx" successful