0

我们有一个使用 wsHttpBinding 的 WCF 服务。我生成的示例请求包括由 WCF 为每个请求验证的时间戳:

  <u:Timestamp u:Id="_0">
    <u:Created>2013-11-02T16:58:24.575Z</u:Created>
    <u:Expires>2013-11-02T17:03:24.575Z</u:Expires>
  </u:Timestamp>

我们最近对服务进行了渗透测试,测试人员注意到可以简单地省略时间戳元素,并且在没有它的情况下接受请求。

我正在审查报告,我想为此添加一个解释。不幸的是,我进行了很好的搜索,但找不到任何解释它的资源,甚至没有提到它。

所以我的问题是:

  1. 为什么这是可选的?
  2. 如果有人问我,是否可以强制使用时间戳?

这是服务绑定配置:

 <wsHttpBinding>
    <binding name="usernameHttps" maxReceivedMessageSize="2147483647">
      <security mode="TransportWithMessageCredential">
        <message clientCredentialType="UserName" establishSecurityContext="false" />
      </security>
    </binding>
  </wsHttpBinding>

这是客户端绑定配置:

<wsHttpBinding>
    <binding name="WSHttpBinding_IService" maxReceivedMessageSize="2147483647">
      <security mode="TransportWithMessageCredential">
        <transport clientCredentialType="None" />
        <message clientCredentialType="UserName" establishSecurityContext="false" />
      </security>
    </binding>
  </wsHttpBinding>
4

1 回答 1

0

从 MS 论坛得到了答案

  1. 为什么这是可选的?

时间戳是选项,因为它是接收者必须对其采取行动,来自 MSDN http://msdn.microsoft.com/en-us/library/ms977327.aspx

" 通过知道创建和过期时间,接收者可以决定数据是否足够新以供自己使用,或者数据是否已经过时以至于应该丢弃消息。"

  1. 如果有人问我,是否可以强制使用时间戳?

是的,如上所述,您的服务逻辑需要这样做,最简单的方法是在 WCF 处理管道中添加一个拦截器,该拦截器将检查此标头,如果未找到,则会引发错误 http://msdn.microsoft.com /en-us/magazine/cc163302.aspx

于 2014-09-03T15:18:41.877 回答