目前需要调用其他公司写的一个CGI,如https://api.abc.com/abc.cgi?uid=aaa
如果直接在IE中打开页面有个返回值(我查看源文件,只有这个返回值,如 1)。
但是我在代码中调用这个CGI时却提示 "基础连接已经关闭: 未能为 SSL/TLS 安全通道建立信任关系。 " 调用代码主要如下(C#): string sException = null;        string sRslt = null;        WebResponse oWebRps = null;        WebRequest oWebRqst = WebRequest.Create(Url);        oWebRqst.Timeout = 50000;        try
        {
            oWebRps = oWebRqst.GetResponse();
            
        }
       .
       . 
       .       就是到 oWebRps = oWebRqst.GetResponse(); 这里出的错,急救啊!

解决方案 »

  1.   

    这个CGI是需要 安全证书的 。
    当调用时,IE地址栏显示的是浅红色,后面还显示 ‘证书错误’
      

  2.   

    public class TrustAllCertificatePolicy : System.Net.ICertificatePolicy         {             public TrustAllCertificatePolicy()             {}               public bool CheckValidationResult(ServicePoint sp,                 System.Security.Cryptography.X509Certificates.X509Certificate cert,                 WebRequest req, int problem)             {                 return true;             }         } 
     
    然后,在请求之前加上 System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy(); 
      

  3.   

    参考资料http://www.cnblogs.com/zhengyun_ustc/archive/2005/04/11/135821.html