asp.net - 带有 Clientcertificate 的 Web 服务在 IIS 中运行时出现错误 Could not create SSL/TLS secure channel

标签 asp.net web-services iis ssl x509certificate

我有以下代码来使用客户端证书访问网络服务。当我在控制台应用程序中运行此代码时,一切似乎都运行良好。如果我尝试从在 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/

相关文章:

web-services - 如何在 RESTful Web 应用程序中映射不同的 UI View ?

c# - 如何使用 HttpClient 发帖?

html - 在 iis 上托管基本的 html 站点

IIS 进程无法访问正在使用的文件

c# - 使用自由图像 API

asp.net - 如何强制 asp.net GridView 控件将第一行包装在 <thead> </thead> 标记中

c# - http.context.user 和 thread.currentprincipal 之间的区别以及何时使用它们?

javascript - 每次单击按钮时如何防止 javascript 重新加载?

web-services - 是否可以使用 Delphi 将 XML 发送和接收到 WSDL 函数?

c# - 模拟不工作 - Asp.Net 核心 3.1 应用程序在 IIS 中托管 Windows 身份验证