C# ';请求被中止:无法创建SSL/TLS安全通道';SSL设置之后
在Windows Server 2008 R2上运行的web服务中,IIS 7.5。我用以下代码设置了一个api调用C# ';请求被中止:无法创建SSL/TLS安全通道';SSL设置之后,c#,iis,ssl,httpwebrequest,C#,Iis,Ssl,Httpwebrequest,在Windows Server 2008 R2上运行的web服务中,IIS 7.5。我用以下代码设置了一个api调用 // ignore untrusted ssl connection ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true; // create web request var httpWebRequest = (H
// ignore untrusted ssl connection
ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
// create web request
var httpWebRequest = (HttpWebRequest)WebRequest.Create(REMOTE_URL);
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
string json = new JavaScriptSerializer().Serialize(REQUEST_STRING);
streamWriter.Write(json);
streamWriter.Close();
}
// fetch response
httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
statusCode = (int)httpResponse.StatusCode;
它工作得很好。之后,我尝试在IIS服务器中安装SSL证书,运行新的HTTPs web服务,并将带有上述代码的模块放入web服务中,噩梦开始了,下面的行开始返回,请求被中止:无法创建SSL/TLS安全通道
httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
我尝试使用旧的web服务回滚,删除了已安装的证书,但没有成功
还尝试了以下方法,但均失败
1) 添加
2) 修改应用程序池标识并将加载用户配置文件设置为True
3) 通过证书MMC在个人证书和中级认证机构证书中添加证书
有点挣扎,所以任何提示和想法都将不胜感激。谢谢。您的意思是您在试图联系的服务器上安装了证书,还是在运行上述代码的服务器上安装了证书?您可能会从中获得一些有用的信息,这些信息将让您准确地了解网络中正在发生的情况(包括正在使用的证书/协议)。@Rob我正在为我的服务器安装证书,上面的代码正在运行,与我调用的远程证书无关。谢谢你的链接,我会试试看。
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;