我有以下代码来使用客户端证书访问网络服务。当我在控制台应用程序中运行此代码时,一切似乎都运行良好。如果我尝试从在 IIS 7 中运行的 Web 应用程序运行它。我收到错误消息“请求已中止:无法创建 SSL/TLS 安全通道。”
这是代码:
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Ssl3 | System.Net.SecurityProtocolType.Tls; //from other stackoverflow case
System.Net.ServicePointManager.Expect100Continue = true; //from other stackoverflow case
db2wsService service = new db2wsService();
service.Url = this.WebserviceUrl;
HttpServerUtility server = HttpContext.Current.Server;
X509Certificate certificate = new X509Certificate(server.MapPath(this.CertificatePath), this.CertificatePassword);
service.ClientCertificates.Add(certificate);
service.PreAuthenticate = true;
//do some stuff here to call webservices
最佳答案
我遇到了同样的问题。这个解决方案是 winhttpcertcfg。如果你在谷歌上搜索关于使用,你会找到它。
关于asp.net - 带有 Clientcertificate 的 Web 服务在 IIS 中运行时出现错误 Could not create SSL/TLS secure channel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14055821/