“无法为SSL/TLS安全通道与办法机构“某链接”建立信任关系”

前言:
作者在制作一个Winform窗体工具时,在解决方案中调用了其他网页的链接Service Reference,但是在程序运行后,提示错误,如图2所示。
图1
图2

----------------------------------------------------------------------------------------解决方法如下----------------------------------------------------------------
查找网上的解决方案后,总结如下:
1、添加using应用
我是直接在当前.cs文件中添加。
using System.Net.Security;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
2、重载CheckValidationResult方法,返回true;
作者在当前类中直接重载的

public bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
        {
            return true;
        }

3、在创建ServiceReference.AppFileServiceSoapClient对象前添加代码行1,其中参数就是CheckValidationResult为重载的名称

System.Net.ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(CheckValidationResult);
                
ServiceReference.AppFileServiceSoapClient WebRef = new ServiceReference.AppFileServiceSoapClient("AppFileServiceSoap");
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值