目前需要调用其他公司写的一个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(); 这里出的错,急救啊!
如果直接在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(); 这里出的错,急救啊!
当调用时,IE地址栏显示的是浅红色,后面还显示 ‘证书错误’
然后,在请求之前加上 System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();