【问题标题】:webHttpBinding security does not contain message node?webHttpBinding 安全不包含消息节点?
【发布时间】:2012-04-10 18:35:43
【问题描述】:

我正在尝试将客户端证书应用于 WCF REST 服务。我发现了一些有关应用具有以下内容的客户端证书的详细信息:

<bindings>
  <wsHttpBinding>
    <binding name="wsHttpEndpointBinding">
      <security>
        <message clientCredentialType="Certificate" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>

在这种情况下,似乎没有问题。但是,我正在使用 webHttpBinding,但我收到一条错误消息,指出 messagesecurity 节点的无效子节点。

我会不正确地设置客户端证书吗?谁能指出我正确的方向。

【问题讨论】:

    标签: wcf web-config client-certificates


    【解决方案1】:

    wsHttpBinding 配置中的消息节点是关于配置 SOAP 消息安全头的,这就是为什么它对 webHttpBinding 无效的原因,它不是基于 SOAP(它是 REST)的

    REST 服务的适当安全性很可能是传输级别 - 即 HTTPS。

    如果您想使用消息级别的安全性,您需要切换到 SOAP,但消息级别是相当专业的,在大多数情况下没有必要。

    如果您需要为 webHttpBinding 使用证书(这意味着使用双向 SSL),您需要将 securityMode 设置为 Transport 并将 clientCredentialType 属性设置为 Certificate。在配置中,在服务器端是这样的

      <webHttpBinding>
        <binding name="ClientCertServerSide">
          <security mode="Transport" >
           <transport clientCredentialType="Certificate"/>
          </security> 
        </binding>
      </webHttpBinding> 
    

    在客户端,您可以在代码中(使用HttpWebRequest.ClientCertificates 属性)或在配置中指定证书。在配置中它看起来像

        <endpointBehaviors>
            <behavior name="ClientCertClientSide">
                <clientCredentials>
                    <clientCertificate findValue="put the cert name here" storeLocation="put the store here" />
                </clientCredentials>
            </behavior>
        </endpointBehaviors>
    

    【讨论】:

      猜你喜欢
      • 2010-09-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多