用 C# 访问有SSL的Web Service

 
    在程序的第一次启动,加入 下面这个代码。就可以访问 SSL了。
ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;

 

 

否则就会报下面的错误。

Failed to load broad.The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.

 

不过我测试服务器的证书是假的。加了上面那句代码可能有安全隐患。
posted @ 2010-08-31 10:14  沉默的糕点  阅读(836)  评论(0编辑  收藏  举报