If you get “The remote certificate is invalid according to the validation procedure” exception while trying to establish SSL connection, most likely your’s server certificate is self-signed or you used incorrect host name to connect (Host name must match the name on certificate, for example ftp.example.com and example.com may point to the same server, but certificate is issued only to ftp.example.com and this is the address you should use).

Good news is that you can accept self-signed certificates using Ftp.dll FTP and FTPS .NET component.

First you need to subscribe to ServerCertificateValidate event.

Then you need to create ValidateCertificate method that validates the certificate (ignores certificate chain and name mismatch errors).

// C# version

using (Ftp client = new Ftp())
{
// we will use custom validation
client.ServerCertificateValidate +=
new ServerCertificateValidateEventHandler(Validate); // Minimalistic version to accept any certificate:
//client.ServerCertificateValidate +=
// (sender, e) => { e.IsValid = true; }; client.ConnectSSL("ftp.example.org");
client.Login("username", "password"); foreach (FtpItem item in client.GetList())
{
if (item.IsFolder == true)
Console.WriteLine("[{0}]", item.Name);
else
Console.WriteLine"{0}", item.Name);
}
client.Close();
} private static void ValidateCertificate(
object sender,
ServerCertificateValidateEventArgs e)
{
const SslPolicyErrors ignoredErrors =
SslPolicyErrors.RemoteCertificateChainErrors | // self-signed
SslPolicyErrors.RemoteCertificateNameMismatch; // name mismatch if ((e.SslPolicyErrors & ~ignoredErrors) == SslPolicyErrors.None)
{
e.IsValid = true;
return;
}
e.IsValid = false;
}

You can download Ftp.dll FTP/FTPS component for .NET here.

(转)The remote certificate is invalid according to the validation procedure的更多相关文章

  1. 解决“The remote certificate is invalid according to the validation procedure”问题

    在用HttpClient发起https请求时,遭遇了“The remote certificate is invalid according to the validation procedure”异 ...

  2. The remote certificate is invalid according to the validation procedure 远程证书验证无效

    The remote certificate is invalid according to the validation procedure   根据验证过程中远程证书无效 I'm calling ...

  3. .net core中Grpc使用报错:The remote certificate is invalid according to the validation procedure.

    因为Grpc采用HTTP/2作为通信协议,默认采用LTS/SSL加密方式传输,比如使用.net core启动一个服务端(被调用方)时: public static IHostBuilder Creat ...

  4. 异常处理之“The remote certificate is invalid according to the validation praocedure.”

    参考文章:http://brainof-dave.blogspot.com.au/2008/08/remote-certificate-is-invalid-according.html 参考文章:h ...

  5. use AP_VENDOR_PUB_PKG.Update_Vendor_Site_Public to u ORA-01722: invalid number in Package AP_VENDOR_PUB_PKG Procedure Update_Vendor_Site_Public

    ORA-01722: invalid number in Package AP_VENDOR_PUB_PKG Procedure Update_Vendor_Site_Public 发现此问题的经过: ...

  6. 使用.NET读取exchange邮件

    公司有个第3方的系统,不能操作源码修改错误捕获,但是错误会发一个邮件出来,里面包含了主要的信息.于是想从邮件下手,提取需要的数据 开始考虑使用的是exchange service,主要参考http:/ ...

  7. ClickOnce发布后不能安装

    当在internet发布用ClickOnce打包的客户端程序时,遇到ClickOnce启动后出错,错误信息如下: + Downloading https://xxxxx/Deploy/pc/Boote ...

  8. SignalR Troubleshooting

    This document contains the following sections. Calling methods between the client and server silentl ...

  9. ef 问题汇总

    持续更新: 一  属性重命名 数据库:UserName Model: [Column("UserName")]public string UserName222 二, 某表多个外键 ...

随机推荐

  1. 编写高质量JS代码中

    前段时间看了几道关于前端javascript的面试题目,方觉函数调用模式等基础的重要性.于是,下定决心,好好补补基础,即便不能深入语言的内部设计模式,也要对基本面向对象概念有比较深入的理解. 继续上一 ...

  2. 2018.11-2019.1的随记|NOIP的考后随记

    就是日记吧?(这里就是写一些乱七八糟的东西qwq,当作自己的零散想念吧 1.24 今天跟着BLUESKY他们的视频一起领略了一下远在广州的CCF冬令营开幕式,看着ljh的拍的照片也体验了一下RM冬令营 ...

  3. Delphi XE8帮助中的REST相关内容。

    Delphi XE8的离线帮助是我见过的最好的Delphi帮助文档了,内容相当详细和丰富,几乎涵盖了Delphi的方方面面!! Delphi XE8的帮助文档在哪里?“XE8安装目录\Help\Doc ...

  4. checkbox attr 和 prop ,onclick 事件,

    给checkbox 添加默认的勾选,尽量使用 checked=“checked”,不要使用checked=“true”. <td><input id="checkboxid ...

  5. file.delete()的优化

    //删除暂存的pdf File file =new File(pdfFilename); file.delete(); Path path2 = Paths.get(pdfFilename); Fil ...

  6. 数据库管理工具navicat基本使用方法——以MySql为例

    mysq数据库管理工具navicat基本使用方法 https://www.cnblogs.com/neuedu/p/5876874.html

  7. 木马APP的简单分析(Android Killer分析)

    本文作者:三星s7edge 一.此贴目的:分析一个木马APP样本的行为.—————————————————————————————————————————————————-二.分析步骤及结果: 文件名 ...

  8. pip安装python库总是超时或出错的解决办法

    建个文件 ~/.pip/pip.conf, 内容如下 [global] timeout = index-url = http://pypi.douban.com/simple/ [install] u ...

  9. js高级程序设计 笔记 --- 面向对象的程序设计

    1,理解对象 通过对象字面量的方式,创建一个对象,为它添加属性和方法: var obj = { a: 1, b:2, sayA(){ console.log(this.a)}} 1,属性类型: 数据属 ...

  10. Sqlite shell 的使用

    学习python中,涉及SQLite3数据库的操作,其中一种是使用sqlite shell,在园子里找到下面这篇文章,跟着试了下,挺好. 这里要注意,语句是C语言规范的吧,语句末尾需要";& ...