相关文章推荐
豪情万千的键盘  ·  ClientDataSet中修改,删除,添加 ...·  1 年前    · 
礼貌的鸡蛋面  ·  ts实现去除字符串空格_Li--AiTao的 ...·  2 年前    · 
兴奋的消防车  ·  Oracle SCN Head ...·  2 年前    · 
坏坏的骆驼  ·  git bfg ...·  2 年前    · 
强健的生姜  ·  4种更快更简单实现Python数据可视化的方 ...·  2 年前    · 
Code  ›  FluentFTP:根据验证过程,远程证书无效开发者社区
https://cloud.tencent.com/developer/ask/sof/114219892/answer/129093689
腼腆的烈马
2 年前
首页
学习
活动
专区
工具
TVP 最新优惠活动
返回腾讯云官网
提问

问 FluentFTP:根据验证过程,远程证书无效

Stack Overflow用户
提问于 2017-05-14 00:03:27
EN

当我试图连接到我的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
1 6.5K 0 票数 2
EN
c#
ftp
ssl-certificate
fluentftp

Stack Overflow用户

回答已采纳

发布于 2017-05-14 03:44:05

Client_ValidateCertificate 需要手动接受这样的证书:

private static void Client_ValidateCertificate(FtpClient control, FtpSslValidationEventArgs e)
    e.Accept = true;
}

然而,盲目地接受任何证书确实是个坏主意。最后我做了这样的事:

private void Client_ValidateCertificate(FtpClient control, FtpSslValidationEventArgs e)
    if (e.PolicyErrors == SslPolicyErrors.None || e.Certificate.GetRawCertDataString() == TrustedRawCertData)
        e.Accept = true;
 
推荐文章
豪情万千的键盘  ·  ClientDataSet中修改,删除,添加数据和Delta属性 - 癫狂编程 - 博客园
1 年前
礼貌的鸡蛋面  ·  ts实现去除字符串空格_Li--AiTao的博客-CSDN博客
2 年前
兴奋的消防车  ·  Oracle SCN Head Room原理精讲 - 墨天轮
2 年前
坏坏的骆驼  ·  git bfg 的使用(删除提交记录中的敏感信息,删除文件等)_Grassto的博客-CSDN博客
2 年前
强健的生姜  ·  4种更快更简单实现Python数据可视化的方法 | 机器之心
2 年前
今天看啥   ·   Py中国   ·   codingpro   ·   小百科   ·   link之家   ·   卧龙AI搜索
删除内容请联系邮箱 2879853325@qq.com
Code - 代码工具平台
© 2024 ~ 沪ICP备11025650号