[英]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.