我正在尝试将这段WSE3.0代码转换为WCF:
// we use Microsoft WSE 3.0 to insert the username token in the soap header.
// This strategy takes care of creating and inserting the Nonce and Created elements
// for us, as well as creating a password digest based on Nonce, Created, and
// the password itself. Refer to the WS-Secutiry UsernameToken Profile 1.1
// specification at http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=wss.
Microsoft.Web.Services3.Security.Tokens.UsernameToken nametoken;
nametoken = new Microsoft.Web.Services3.Security.Tokens.UsernameToken(username, password, Microsoft.Web.Services3.Security.Tokens.PasswordOption.SendHashed);
Microsoft.Web.Services3.Design.Policy ClientPolicy = new Microsoft.Web.Services3.Design.Policy();
ClientPolicy.Assertions.Add(new UsernameOverTransportAssertion());
this._proxy.SetPolicy(ClientPolicy);
this._proxy.SetClientCredential<UsernameToken>(nametoken);我已经非常接近了,除了以摘要模式发送密码(上面代码中的Microsoft.Web.Services3.Security.Tokens.PasswordOption.SendHashed`):
TransportSecurityBindingElement transportBindingElement =
SecurityBindingElement.CreateUserNameOverTransportBindingElement();
transportBindingElement.AllowInsecureTransport = true;
transportBindingElement.EnableUnsecuredResponse = true;
transportBindingElement.IncludeTimestamp = true;
var binding = new CustomBinding(new BindingElement[] { //
transportBindingElement, //
new TextMessageEncodingBindingElement() {
MessageVersion = MessageVersion.Soap11
}, //
new HttpTransportBindingElement() {
AuthenticationScheme = AuthenticationSchemes.Digest,
}, //
});上面的代码仍然以纯文本(未经过散列)的形式发送密码。我发现有人试图转换类似的代码,有人说如果不写一个自定义的令牌序列化程序,就不可能设置WCF来做这件事,我发现这个link。
这个说法准确吗?
如果是,我需要做什么来创建和使用这个自定义序列化程序?
它看起来这个link可能是一个很好的起点,当结合从网站linked的Password_Digest = Base64 ( SHA-1 ( nonce + created + password ) )在评论中,给出了以下公式Password_Digest = Base64 ( SHA-1 ( nonce + created + password ) ),但如果谁有更好的解释,确切地说,我需要从和如何让WCF使用我的新序列化程序,我很乐意听到。
发布于 2011-08-06 02:46:09
你找到我的问题了:)
这是一个非常有趣的问题。微软经常被指责生产不安全的系统和API,正因为如此,微软的一些工程师开始纳入一些关于什么是安全的,什么不是新的API的想法。具有摘要密码的UserNameToken配置文件正是这种努力的结果。它被认为不够安全,因此从WCF中完全省略了它。好吧,如果WCF不是一个与其他平台和框架互操作的应用程序接口,这应该不是问题,在这些平台和框架中,带有摘要密码的UserNameToken配置文件非常流行。
是的,当我们解决这个问题时,我们做了定制的令牌序列化程序。它不仅仅是关于令牌序列化的。实际上,您必须实现相当多的类才能使其工作。我不会分享我们的实现,因为它不是我的代码,但你可以尝试this one。
https://stackoverflow.com/questions/6960396
复制相似问题