我有一个带有 wsHttpBinding 的 WCF 服务,我的客户端是我的 Windows 应用程序和我的网站。这两个客户都是我的服务的消费者。在我的服务中,我使用消息安全性和用户名 clientCredentialType 进行客户端身份验证。我不想使用任何证书进行此身份验证。我如何能?或者您为此向我建议其他解决方案?
最佳答案
具有 UserName 客户端凭据的 WsHttpBinding 消息安全性需要服务器证书。唯一的选择是使用 Windows 客户端凭据,但在这种情况下,您的客户端和服务必须位于同一 AD 域(或受信任域)中。如果您想保护消息(加密和签名),您需要这样的基础设施。
编辑:
根据您的评论,您不需要消息安全性,您只想使用 UserNameToken 配置文件通过不安全的 channel 传输客户端凭据。这在 WCF 4 中是可能的(以及具有特殊 KB 的旧版本)。尝试这个自定义绑定(bind):
<customBinding>
<binding name="UsernamePasswordOverHttp">
<textMessageEncoding messageVersion="Soap11" />
<security
authenticationMode="UserNameOverTransport"
messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10"
allowInsecureTransport="true" />
<httpTransport />
</binding>
</customBinding>
请注意,为此类服务自动生成 WSDL 可能会出现一些问题。
编辑2:
另一种可能性是使用 ClearUserNameBidning .
关于wcf - 如何在 WCF 服务中使用消息安全性和用户名 clientCredentialType 而无需证书?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4725096/