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/Kerberos 的目的,客户端无法根据目标地址“ http://myServerUrl ”中的身份确定服务主体名称。目标地址身份必须是 UPN 身份(如 acmedomain\alice)或 SPN 身份(如 host/bobs-machine)。

这个问题的原因可能是什么?

4

1 回答 1

0

默认 ClientCredentialType 似乎是 Windows,这就是您收到与 Sspi/Kerberos 相关的错误的原因。您需要将“证书”指定为凭证类型,并在客户端凭证容器中设置实际证书。查看此链接的客户端部分以获取更多详细信息:

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

于 2012-02-05T18:37:04.693 回答