简体   繁体   English

该请求已中止:使用X509Certificate2时无法创建SSL / TLS安全通道

[英]The request was aborted: Could not create SSL/TLS secure channel when using X509Certificate2

I have a Web API that requires Client Certificate Authentication, Whenever I provide correct Client Certificate I get an error Could not Create SSL/TLS Secure Channel. 我有一个需要客户端证书身份验证的Web API,每当我提供正确的客户端证书时,都会出现错误,无法创建SSL / TLS安全通道。

My app is hosted on IIS Server from where I am accessing the API. 我的应用程序托管在我访问API的IIS服务器上。 While executing the API through code I can get the desired result but when the app is hosted on IIS and then if the request is executed then I get the error. 通过代码执行API时,我可以获得期望的结果,但是当应用程序托管在IIS上时,如果执行了请求,则会收到错误消息。

My Code : 我的代码:

     myHttpWebRequest.ClientCertificates.Add(New X509Certificate2(certificate, myService.CertificateSettings.Certificate_Password.Decrypt))
     Dim response = myHttpWebRequest.GetResponse()

What could be the possible reason? 可能是什么原因?

this can be complex to resolve - you can ignore these errors using the following code - not recommended... 解决起来可能很复杂-您可以使用以下代码忽略这些错误-不建议...

   ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, errors) => {      
      return true;
   };

Alternatively examine the error and try to fix your certificate: 或者检查错误并尝试修复证书:

     ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, errors) =>
        {
            SslPolicyErrors result = errors;
            Console.WriteLine(result);

        };

What SSL policy errors do you get? 您会得到什么SSL策略错误?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 具有X509Certificate2的C#HttpClient-WebException:请求已中止:无法创建SSL / TLS安全通道 - C# HttpClient with X509Certificate2 - WebException: The request was aborted: Could not create SSL/TLS secure channel 使用X.509对Web服务进行身份验证时出现“无法创建SSL / TLS安全通道”错误 - “Could not create SSL/TLS secure channel” error when authenticating to a web service using X.509 HttpClientHandler / 请求被中止:无法创建 SSL/TLS 安全通道 - HttpClientHandler / The request was aborted: Could not create SSL/TLS secure channel 请求已中止:无法创建SSL / TLS安全通道 - SecurityProtocol行为 - The request was aborted: Could not create SSL/TLS secure channel - SecurityProtocol behavior .NET请求已中止:无法创建SSL / TLS安全通道 - .NET The request was aborted: Could not create SSL/TLS secure channel WebException:请求已中止:无法创建SSL / TLS安全通道 - WebException: The request was aborted: Could not create SSL/TLS secure channel 请求已中止:无法创建SSL / TLS安全通道异常 - The request was aborted: Could not create SSL/TLS secure channel Exception HttpWebRequest:请求已中止:无法创建SSL / TLS安全通道 - HttpWebRequest: The request was aborted: Could not create SSL/TLS secure channel 请求被中止:无法创建 SSL/TLS 安全通道 - The request was aborted: Could not create SSL/TLS secure channel 该请求已中止:无法创建SSL / TLS安全通道.Net 4.5.2 - The request was aborted: Could not create SSL/TLS secure channel .Net 4.5.2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM