1

我需要访问我们的某个合作伙伴的Web服务。 他们的服务通过客户端证书和基本身份验证进行保护。 我用BasicHttpBinding使用WCF。带客户端证书和基本身份验证的WCF客户端

我能够使用传输级别安全性挂接证书。 我知道证书正在工作,因为我不再收到403错误,但我收到了401,因为我无法将证书和传输一起传递。 从我所看到的,我只能有一种运输安全方案。

我该如何做到这一点?

<security mode="Transport"> 
    <transport type="Certificate" /> 
    <transport type="Basic" /> 
</security> 

感谢

+0

请出示客户代码试图访问WCF服务... – Yahia

+0

你能澄清服务配置。他们使用WCF吗?如果是这样,你可以显示web.config或服务配置代码吗? –

+0

配置使用基本身份验证的传输级别使用SSL(不是双向SSL),还使用客户端证书进行消息级别加密? –

回答

3

你有没有试图通过在消息级别的凭证。 你的配置应该是这样的:

<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"; 
+3

该问题表明他正在使用基本认证 - 因此是传输级别,而不是消息级别。 –