I am getting the following error during a web service request to a remote web service:

Could not establish trust relationship for the SSL/TLS secure channel. ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.

Is there anyway to ignore this error, and continue?

It seems the remote certificate is not signed.

The site I connect to is www.czebox.cz - so feel free to visit the site, and notice even browsers throw security exceptions.

推荐答案

Add a certificate validation handler. Returning true will allow ignoring the validation error:

ServicePointManager
    .ServerCertificateValidationCallback += 
    (sender, cert, chain, sslPolicyErrors) => true;

.net相关问答推荐

Docker镜像mcr.microsoft.com/dotnet/aspnet:8.0不能在Windows上构建

AutoMapper在实体框架查询后不知从哪里带来数据

仅使用 .NET GetBytes 方法转换有效字节而不创建问号

如何计算给定2个字符串的距离相似性度量?

类似于字典但没有值的 C# 数据 struct

为什么这两个比较有不同的结果?

为什么 StyleCop 建议在方法或属性调用前加上this?

使用 .NET 在 Windows 中创建弹出式 toastr 通知

如何删除只读文件?

.NET 世界是否有 Maven 替代方案或端口?

注册 COM 互操作与使程序集 COM 可见

如何找到 ManualResetEvent 的状态?

如何使用转储文件来诊断内存泄漏?

如何正确停止BackgroundWorker

基于多个字符分隔符拆分字符串

在 .NET (C#) 中本地存储数据的最佳方式

如何在 WebBrowser 控件中注入 Javascript?

将日期时间转换为时间跨度

如何从 HashSet 中检索实际项目?

为 webClient.DownloadFile() 设置超时