【问题标题】:Can you test a certificate-secured WCF service with SoapUI?您可以使用 SoapUI 测试受证书保护的 WCF 服务吗?
【发布时间】:2012-02-28 08:03:16
【问题描述】:

我有一个 WCF 服务:

  • 使用BasicHttpBinding(如果你能回答WsHttpBinding就更好了!)
  • 使用TransportWithMessageCredential安全
  • 使用 X.509 证书确保传输和消息安全

我希望能够使用 SoapUI 测试此服务。

但是,当我尝试这样做时,SoapUI 签署的消息似乎比 WCF 预期的要多,从而导致此错误(在启用 ServiceModel 审核后在应用程序日志中检测到):

CryptographicException: Unable to resolve the '#id-100' URI in the signature to compute the digest.

或者,当我使用 WsHttpBinding 时,我得到了异常:

MessageSecurityException: The message received over Transport security has unsigned 'To' header.

以前曾提出过类似的问题:

这并不是一个“Java 与 MS WCF 对话”的问题——我有一个 Java 测试客户端可以正常工作。同样,我可以使用 WCFStorm 来测试服务。然而,SoapUI 已成为一种事实上的测试标准,尤其是对于非 Windows 用户而言。

那么,有没有人设法克服这些问题并使用 SoapUI 测试受证书保护的 WCF 服务?

谢谢

我相信这个问题是无法解决的,基于我自己的测试和 250 赏金没有产生答案。

“web.config”是动态生成的,但它有效地匹配以下任一绑定:

<wsHttpBinding>
    <binding name="WSHttpBinding_ITwoWayAsync" closeTimeout="00:01:00"
        openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
        bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
        maxBufferPoolSize="250000" maxReceivedMessageSize="250000"
        messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
        allowCookies="false">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
          maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      <security mode="TransportWithMessageCredential">
        <transport clientCredentialType="Certificate" proxyCredentialType="None" realm="" />
        <message clientCredentialType="Certificate" negotiateServiceCredential="false"
                 establishSecurityContext="false"
            algorithmSuite="Default" />
      </security>
    </binding>
  </wsHttpBinding>

 <basicHttpBinding>
    <binding name="BasicHttpBinding_ITwoWayAsync" closeTimeout="00:01:00"
        openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
        bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
        maxBufferPoolSize="250000" maxReceivedMessageSize="250000"
        messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
        allowCookies="false">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
          maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      <security mode="TransportWithMessageCredential">
        <transport clientCredentialType="Certificate" proxyCredentialType="None" realm="" />
        <message clientCredentialType="Certificate"  algorithmSuite="Default" />
      </security>
    </binding>
  </basicHttpBinding>

【问题讨论】:

  • 您能在 web.config 文件中分享您的 system.servicemodel 设置吗?

标签: wcf biztalk x509certificate soapui


【解决方案1】:

这对于 SoapUI 是不可能的,我不得不使用另一个名为 WCFStorm 的工具。

【讨论】:

    【解决方案2】:

    我遇到了完全相同的问题。我还没有与BasicHttpBinding 一起使用,但确实可以与WsHttpBinding 一起使用。我也有错误The message received over Transport security has unsigned 'To' header。我创建了一篇博文来解决这个问题。更多信息请查看博文Connect SoapUI to WCF service certificate authentication

    您必须设置签名中的部分。默认情况下,SoapUI 对整个请求进行签名,但这不是 WCF 的默认设置,因此我们必须设置要签名的部分。所以添加名称“To”,命名空间“http://www.w3.org/2005/08/addressing”(这是我的命名空间,但请检查你的)并将编码设置为“元素”。还要检查您请求中的 WS-A 面板。检查地址并设置默认的“收件人”复选框。

    【讨论】:

      【解决方案3】:

      我已经能够使用 WCF 中的自定义绑定和 PFX 证书文件来做到这一点。我必须使用自定义绑定,因为我需要限制对一个证书的访问——这超出了这个问题的范围。我的证书 pfx 文件同时具有公钥和私钥。私钥受密码保护。我无法使用任何其他证书格式来完成这项工作。

      在 SoapUI 中,我转到文件 -> 首选项 -> SSL 设置: -->密钥库名称:path_to_PFX_file -->KeyStore 密码:your_private_key_password

      这是我的 web.config 设置,与 basicHttpBinding 几乎相同:

      <customBinding>
      <binding name="MyServiceBindingConfiguration">
         <security authenticationMode="UserNameOverTransport" includeTimestamp="false" requireDerivedKeys="false" securityHeaderLayout="Lax" messageProtectionOrder="SignBeforeEncrypt" messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
            <localClientSettings maxClockSkew="00:30:00" />
            <localServiceSettings maxClockSkew="00:30:00" />
            <secureConversationBootstrap />
         </security>
         <textMessageEncoding messageVersion="Soap11">
            <readerQuotas maxDepth="32" maxStringContentLength="524288" maxArrayLength="524288" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
         </textMessageEncoding>
         <httpsTransport requireClientCertificate="true" />
      </binding>
      </customBinding>
      

      希望这会有所帮助。

      【讨论】:

      • 嗨,纳希特。感谢您的反馈,但此示例看起来没有消息安全性(只是传输安全性)。 IE。您的消息未经过证书签名。
      • 有趣...我认为因为有一个 messageProtectionOrder="SignBeforeExcrypt",它会对消息进行签名然后加密它。我需要做更多的研究。顺便说一句,只是一个随机的想法 - 也许 messageProtectionOrder 在 basic/wsHttpBinding 和 SoapUI 之间是不同的......
      • 问题似乎是(来自链接的文章)SoapUI 在使用 WsHttp 时没有对 'To' 元素进行签名,并且在使用 BasicHttp 时签署了太多元素。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-01-13
      • 2019-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多