代码之家  ›  专栏  ›  技术社区  ›  Landstander

在使用传输安全性的同时为多个消息保护级别配置服务

  •  1
  • Landstander  · 技术社区  · 11 年前

    我有一个WCF服务,我想对它使用消息签名,但只对某些调用使用,其余的不应该签名。我不知道如何设置它来支持两者。

    消息签名使用非windows用户名和密码,该用户名和密码由服务端的用户名密码验证器验证。已签名和未签名的消息都应该使用传输安全性。

    下面是我的界面示例:

    [ServiceContract(ProtectionLevel=ProtectionLevel.None)]
    public interface ISecTest
    {
        [OperationContract(ProtectionLevel = ProtectionLevel.Sign)]
        string GetData(string value);
    
        [OperationContract(ProtectionLevel = ProtectionLevel.None)]
        string GetStuff(string stuff);
    
    }
    

    我遇到的问题是,签名似乎完全基于服务的绑定配置,而不是接口上定义的ProtectionLevels。

    如果我使用以下绑定, 二者都 调用将需要用户名凭据,而不考虑ProtectionLevel属性:

    <wsHttpBinding>
        <binding name="secureWSHttpBindingConfig">          
          <security mode="TransportWithMessageCredential">
            <message clientCredentialType="UserName" />
            <transport clientCredentialType="None" />
          </security>
        </binding>
      </wsHttpBinding>
    

    如果我省略了消息安全性并使用以下绑定,那么 也不 呼叫需要凭据:

    <wsHttpBinding>
        <binding name="tolerantWSHttpBindingConfig">
          <security mode="Transport">           
            <transport clientCredentialType="None" />
          </security>
        </binding>
      </wsHttpBinding>
    

    除了使用消息安全性之外,还使用传输安全性,这是否会造成复杂性? 关于如何在一项服务中实现这一点(如果可能的话),有什么建议吗?

    谢谢

    1 回复  |  直到 11 年前
        1
  •  0
  •   Rick Rainey    11 年前

    当您使用传输安全性时,您不能混合您的保护级别。如果这对你来说很重要,你就必须使用消息安全性。