2009-09-01 70 views
3

我試圖通過直接通道接口使用與SecurityMode: Message的WSHttpBinding爲WCF服務構建最小客戶端。通過通道接口支持消息級安全性的最小客戶端

我當前的代碼很簡單:

EndpointIdentity i = EndpointIdentity.CreateX509CertificateIdentity(clientCertificate); 
EndpointAddress a = new EndpointAddress(new Uri("http://myServerUrl"), i); 
WSHttpBinding b= new WSHttpBinding(SecurityMode.Message); 
ChannelFactory<IRequestChannel> channelFactory = new ChannelFactory<IRequestChannel>(b, a); 
channelFactory.Open(); 
IRequestChannel channel = channelFactory.CreateChannel(); 
channel.Open(); 
Message response = channel.Request(requestMessage); 

則ClientCertificate得到正確加載。 但是,之後,我不確定是否以正確的方式調用每個函數。

事實是:該代碼段的最後一行拋出一個MessageSecurityException與內容

客戶端無法確定基於在SspiNegotiation的目的,目標地址「http://myServerUrl」的身份服務主體名稱/ Kerberos的。目標地址標識必須是UPN標識(如acmedomain \ alice)或SPN標識(如host/bobs-machine)。

這是什麼原因造成的?

回答

0

默認的ClientCredentialType似乎是Windows,這就是爲什麼你會得到與Sspi/Kerberos相關的錯誤。您需要指定「證書」作爲憑證類型,並在客戶端憑證容器中設置實際證書。查看此鏈接的客戶端部分了解更多詳情:

http://msdn.microsoft.com/en-us/library/ms733098.aspx

相關問題