【发布时间】:2011-09-09 16:48:39
【问题描述】:
我有一个来自第三方的自签名证书 (.cer) 文件。我想在代码中使用该证书来连接到他们的网络服务(通过 HTTPS),而不是将其安装在我的 Windows 证书存储中。具体来说,这样团队中的所有其他开发人员就不必在本地安装此证书以使连接为他们工作。
有没有办法在代码中做到这一点?它可以使用老式的 webservice-client 代码(使用 wsdl.exe 或 VS 的 Add Web Reference)或 WCF 客户端代码(使用 svcutil.exe 或 VS 的 Add Service Reference)——我们还没有确定我们想要走的路还没有。
我试过了:
proxy.ClientCertificates.Add(X509Certificate.CreateFromCertFile(@"d:\temp\mycert.cer"));
使用老式 Web 服务代码,运气不好 - 在我实际在证书存储中安装证书之前,它仍然会因 Could not establish trust relationship for the SSL/TLS secure channel. 而失败。同样的事情:
<identity>
<certificate encodedValue="the base64 encoded contents of the file" />
</identity>
在 app.config 的端点中使用 WCF 客户端技术。
谢谢
【问题讨论】:
标签: .net web-services certificate wcf-client self-signed