繁体   English   中英

带有Clientcertificate的Web服务给出错误在IIS中运行时无法创建SSL / TLS安全通道

[英]Webservice with Clientcertificate gives error Could not create SSL/TLS secure channel when running in IIS

我有以下代码,可使用客户端证书访问Web服务。 当我在控制台应用程序中运行此代码时,一切似乎都可以正常工作。 如果我尝试从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。 如果您在google上搜索有关使用的信息,则会找到它。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM