具有客户端证书和基本身份验证的WCF客户端 [英] WCF client with Client Certificate and Basic Authentication
问题描述
我需要访问我们合作伙伴之一的Web服务. 他们的服务通过客户端证书和基本身份验证来保护. 我正在将WCF与BasicHttpBinding一起使用.
I need to access web services of one of our partners. Their services are secured with both a Client Certificate and Basic Authentication. I'm using WCF with BasicHttpBinding.
我能够使用传输级安全性来连接证书. 我知道证书正在工作,因为我不再遇到403错误,但我却得到401错误,因为我无法随传输一起传递凭据. 据我所知,我只能拥有一种类型的运输安全方案.
I am able to hook up the cert using Transport level security. I know the cert is working because I'm no longer getting a 403 error, but I am getting a 401 because I can't pass the credentials along with the transport. From what I can see, I can only have one type of transport security scheme.
我该如何实现?
<security mode="Transport">
<transport type="Certificate" />
<transport type="Basic" />
</security>
谢谢
推荐答案
您是否尝试过在消息级别传递凭据. 您的配置应如下所示:
Did you tried to pass credential at message level. Your config should look like:
<security mode="Transport">
<transport clientCredentialType="Certificate" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
然后在代码中
WebServiceProxy objClient = new WebServiceProxy ();
objclient.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindBySubjectName, "clientCert");
objClient.ClientCredentials.UserName.UserName = "username";
objClient.ClientCredentials.UserName.Password = "Password";
这篇关于具有客户端证书和基本身份验证的WCF客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!