如何在WCF服务中使用没有证书的Message security和UserName clientCredentialType?

时间:2011-01-18 14:18:25

标签: wcf security

我有一个带有wsHttpBinding的WCF服务,我的客户端是我的Windows应用程序和我的网站。这两个客户都是我服务的消费者。在我的服务中,我使用Message security和UserName clientCredentialType进行客户端身份验证。我不想使用任何证书进行此身份验证。我如何能?或者你为此建议给我其他解决方案?

2 个答案:

答案 0 :(得分:3)

使用UserName客户端creadentials的WsHttpBinding消息安全性需要服务器证书。唯一的选择是使用Windows客户端凭据,但在这种情况下,您的客户端和服务必须位于同一个AD域(或受信任的域)中。如果您想保护消息(加密和签名),您需要这样的基础设施。

修改

根据您的评论,您不需要邮件安全性,您只想使用UserNameToken配置文件在不安全的通道上传输客户端凭据。这在WCF 4(以及具有特殊KB的旧版本)中是可能的。试试这个自定义绑定:

<customBinding>
  <binding name="UsernamePasswordOverHttp">
    <textMessageEncoding messageVersion="Soap11" />
    <security
      authenticationMode="UserNameOverTransport"
      messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10"
      allowInsecureTransport="true" />
    <httpTransport />
  </binding>
</customBinding>

请注意,为此类服务自动生成WSDL可能会出现问题。

编辑2:

另一种可能性是使用ClearUserNameBidning

答案 1 :(得分:1)

谢谢你的榜样。我用你的例子,但我收到了这个错误:

无法为此绑定计算Scheme,因为此CustomBinding缺少TransportBindingElement。每个绑定必须至少有一个派生自TransportBindingElement的绑定元素。

和我的其他问题:对于这个解决方案,我使用VS2010中的哪个项目类型?项目或WCF服务网站中的WCF服务库。哪一个?

谢谢你的回答。