asp.net页面去调用通过SSL加密的webservice报错
来源:互联网 发布:小腿肌肉 知乎 编辑:程序博客网 时间:2024/06/07 17:16
通过C#访问webservice时遇到一个问题,首先通过对方提供的wsdl生成了调用代理类,在测试能否正常访问时,本机调试(http协议)一切正常,当访问正式环境时(https协议),总是报“基础连接已经关闭: 未能为 SSL/TLS 安全通道建立信任关系”InnerException信息为:根据验证过程,远程证书无效。
在网上找到解决方法:
http://social.microsoft.com/Forums/zh-CN/wcfzhchs/thread/1591a00d-d431-4ad8-bbd5-34950c39d563
依照上面的描述操作,问题解决,以作纪念
分以下三步:
1.添加引用
using System.Net;
using System.Net.Security;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
2.在生成的代理类中添加RemoteCertificateValidate函数
private static bool RemoteCertificateValidate(object sender, X509Certificate cert,X509Chain chain, SslPolicyErrors error)
{
System.Console.WriteLine("Warning, trust any certificate");
//为了通过证书验证,总是返回true
return true;
}
3.在生成的代理类的构造函数中添加
//验证服务器证书回调
ServicePointManager.ServerCertificateValidationCallback += RemoteCertificateValidate;
在网上找到解决方法:
http://social.microsoft.com/Forums/zh-CN/wcfzhchs/thread/1591a00d-d431-4ad8-bbd5-34950c39d563
依照上面的描述操作,问题解决,以作纪念
分以下三步:
1.添加引用
using System.Net;
using System.Net.Security;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
2.在生成的代理类中添加RemoteCertificateValidate函数
private static bool RemoteCertificateValidate(object sender, X509Certificate cert,X509Chain chain, SslPolicyErrors error)
{
System.Console.WriteLine("Warning, trust any certificate");
//为了通过证书验证,总是返回true
return true;
}
3.在生成的代理类的构造函数中添加
//验证服务器证书回调
ServicePointManager.ServerCertificateValidationCallback += RemoteCertificateValidate;
0 0
- asp.net页面去调用通过SSL加密的webservice报错
- asp.net页面去调用通过SSL加密的webservice报错
- jquery调用asp.net webservice报错
- 通过SSL调用WebService
- 通过SSL调用WebService
- Webservice 通过SSL加密传输
- Webservice 通过SSL加密传输
- jQuery Ajax 调用 Asp.Net WebService 报错 (vs2005)
- cxf调用.net webservice 报错的解决方法
- .net调用java发布的webservice soap报错
- ASP调用.net webservice
- asp.net调用WebService
- Asp.net调用webservice
- Asp.net调用webservice
- ASP如何调用。Net的WebService
- jQuery调用ASP.NET的WebService
- asp.net调用java写的webservice
- jQuery如何调用ASP.NET的WebService
- SQL注入漏洞全接触--高级篇 [3]
- Tiny服务的开发配套的工具来了
- 设计模式之十四:备忘录模式(Memento)
- 五、JAVA中类的探究-类变量的初始化时机
- objective-c与javascript交互
- asp.net页面去调用通过SSL加密的webservice报错
- Spring mvc 返回json格式
- mybatis 异常:There is no getter for property named 'classId' in 'class java.lang.Integer'
- Tiny代码生成框架
- Edit控件事件响应及自动换行,刷屏
- 对TinyTemplate进行性能优化过程简介
- 谷歌服务,想说爱你不容易
- Cookie与Session的区别于用法
- java私塾高级设计模式视频链接