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

該問題表明他正在使用基本認證 - 因此是傳輸級別,而不是消息級別。 –