1

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

消息签名使用由服务端的 usernamepasswordvalidator 验证的非 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>

除了消息安全性之外,这是否是使用传输安全性的复杂因素?关于如何在单个服务中完成此操作的任何建议(如果可能的话)?

谢谢!

4

1 回答 1

0

使用传输安全性时,不能混合保护级别。如果这对您很重要,您将不得不使用消息安全性。

于 2013-08-27T05:26:16.687 回答