【问题标题】:Manual addressing with secure customBinding on WCF service在 WCF 服务上使用安全 customBinding 手动寻址
【发布时间】:2012-01-23 13:13:32
【问题描述】:

我正在为外部定义的 WSDL 开发 Web 服务。使用 HTTP/S(服务器和客户端证书)进行访问,请求和响应都使用各自的证书进行签名。我已经在 VS2010 中导入了带有服务引用的 WSDL,并向 MessageContracts 添加了签名,设置了配置文件以执行安全性和 https 并在端口上设置 SSL。 我快要让它工作了,但我需要启用手动寻址以在响应中插入 wsa:To 元素,但不知道如何让它工作.. 任何帮助表示赞赏。

这是我当前的配置部分:

<bindings>
  <customBinding>
    <binding name="AfleverServiceSoapBinding_V1_1">
      <security defaultAlgorithmSuite="TripleDesRsa15"
                authenticationMode="MutualCertificateDuplex"
                requireDerivedKeys="false"
                securityHeaderLayout="Lax"
                includeTimestamp="true"
                keyEntropyMode="CombinedEntropy"
                messageProtectionOrder="EncryptBeforeSign"
                messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10"
                requireSignatureConfirmation="false"
                allowSerializedSigningTokenOnReply="true"
                enableUnsecuredResponse="False">
        <localClientSettings cacheCookies="true"
                             detectReplays="true"
                             replayCacheSize="900000"
                             maxClockSkew="00:05:00"
                             maxCookieCachingTime="10:00:00"
                             replayWindow="00:05:00"
                             sessionKeyRenewalInterval="10:00:00"
                             sessionKeyRolloverInterval="00:05:00"
                             reconnectTransportOnFailure="true"
                             timestampValidityDuration="00:05:00"
                             cookieRenewalThresholdPercentage="60"/>
        <localServiceSettings detectReplays="true"
                              issuedCookieLifetime="10:00:00"
                              maxStatefulNegotiations="128"
                              replayCacheSize="900000"
                              maxClockSkew="00:05:00"
                              negotiationTimeout="00:01:00"
                              replayWindow="00:05:00"
                              inactivityTimeout="00:02:00"
                              sessionKeyRenewalInterval="15:00:00"
                              sessionKeyRolloverInterval="00:05:00"
                              reconnectTransportOnFailure="true"
                              maxPendingSessions="128"
                              maxCachedCookies="1000"
                              timestampValidityDuration="00:05:00"/>
        <secureConversationBootstrap/>
      </security>
      <mtomMessageEncoding maxReadPoolSize="64"
                           maxWritePoolSize="16"
                           messageVersion="Soap11WSAddressing10"
                           maxBufferSize="65536"
                           writeEncoding="utf-8">
        <readerQuotas maxDepth="32"
                      maxStringContentLength="8192"
                      maxArrayLength="16384"
                      maxBytesPerRead="4096"
                      maxNameTableCharCount="16384" />
      </mtomMessageEncoding>
      <httpsTransport manualAddressing="false"
                      maxBufferPoolSize="524288"
                      maxReceivedMessageSize="65536"
                      allowCookies="false"
                      authenticationScheme="Anonymous"
                      bypassProxyOnLocal="false"
                      decompressionEnabled="true"
                      hostNameComparisonMode="StrongWildcard"
                      keepAliveEnabled="true"
                      maxBufferSize="65536"
                      proxyAuthenticationScheme="Anonymous"
                      realm=""
                      transferMode="Buffered"
                      unsafeConnectionNtlmAuthentication="false"
                      useDefaultWebProxy="true"
                      requireClientCertificate="true" />
    </binding>
  </customBinding>
</bindings>

其中大部分是自动生成的。

我知道我需要将httpsTransport 上的manualAddressing 属性设置为true,但随后出现异常,因为此设置处于消息级安全性。 有谁知道如何切换到传输级安全性同时保持其余部分不变?由于这是customBinding,因此security 元素上的mode 属性不可用。

非常感谢,步态。

顺便说一句,我知道如何在代码中设置wsa:To,但是除非我可以转到手动寻址,否则它会在编码响应中丢失。..

【问题讨论】:

    标签: wcf security manual ws-addressing custom-binding


    【解决方案1】:

    查看Nicholas Allen's Indigo Blog on Manual Addressing。概括;并非所有传输都支持手动寻址。如果该选项在传输中可用,则需要 3 个步骤才能使其发挥作用。

    首先,确保您使用的传输支持某种形式的手动寻址。如果不是,那么您在将消息发送到不同目的地而不在每个目的地创建一些新对象方面就不走运了。其次,打开该手动寻址选项以防止在消息发送期间自动应用寻址标头。第三,使用您想将自己的地址标头应用于传出消息的任何方法。如果你只是在代理上进行服务调用,那么你会想要使用这样的东西:

    OperationContext.Current.OutgoingMessageHeaders.To = this.replyTo.Uri;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-03-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-10
      • 2013-10-14
      • 1970-01-01
      相关资源
      最近更新 更多