提问人:Salfredo 提问时间:10/4/2023 更新时间:10/4/2023 访问量:13
使 WebRequest 在调试时有效,但给出“请求已中止:无法创建 SSL/TLS 安全通道”错误 anywere other
Making a WebRequest works while debuging but gives "The request was aborted: Could not create SSL/TLS secure channel" error anywere else
问:
我正在制作一项需要向 soap 服务发送请求的服务。 此调用需要使用 pfx 文件中的证书。 该代码在调试时有效,但在测试服务器中出现错误“请求已中止:无法创建 SSL/TLS 安全通道”。
该调用在两台具有 soapUI 的计算机中都有效。
我的代码如下所示:
//Create the http request
HttpWebRequest getDocumentpdfRequest = (HttpWebRequest)WebRequest.Create(requestUrl);
//Add content type
getDocumentpdfRequest.ContentType = "text/xml;charset=UTF-8";
//Add method
getDocumentpdfRequest.Method = "POST";
//Add SOAP action
getDocumentpdfRequest.Headers.Add("SOAPAction", "GetDocumentMTOM");
//Add the certificate to the request
getDocumentpdfRequest.ClientCertificates.Add(cert);
WebResponse getDocumentpdfResponse = getDocumentpdfRequest.GetResponse();
我已经添加了“ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;”
答: 暂无答案
评论