【问题标题】:The binding contains both an AsymmetricSecurityBindingElement and a secure transport binding element绑定包含 AsymmetricSecurityBindingElement 和安全传输绑定元素
【发布时间】:2014-01-31 15:15:12
【问题描述】:

我们有如下要求:

ESB 集成要求:

客户使用 ESB 服务 (IBM) 为集成应用程序和服务提供连接。 我们有一个服务 (WCF) 将由另一个供应商通过 ESB 集成调用 将 WCF 服务与 ESB 集成的安全要求是,WS-Security 用于签名,但对于加密,我们应该使用 HTTPS 根据他们与我们共享的策略文件,我们应该使用非对称绑定,令牌仅发送给接收者,而不是发起者 消息版本为 SOAP11 他们给了我们一个证书(X509),我们在 WCF 服务配置文件中将其配置为客户端证书,我们将自己的证书用于 WCF 服务 WCF 实现与他们预期的 WS-Policy 相匹配:

我们开发了WCF服务(.Net 3.5,有技术要求选择.net 3.5) WCF 服务配置为使用身份验证模式 MutualCertificateDuplex,对于消息安全版本,它使用“WSSecurity10WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10” 它还被配置为使用 CustomBinding 来匹配 ESB 的要求 以下是我们用于 WCF 服务的配置:

<system.serviceModel>

    <behaviors>
      <serviceBehaviors>
        <behavior name="My.Services.ResourceManagementServiceBehavior">
          <serviceSecurityAudit auditLogLocation="Application" suppressAuditFailure="true"
            serviceAuthorizationAuditLevel="SuccessOrFailure" messageAuthenticationAuditLevel="SuccessOrFailure" />
          <serviceMetadata httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceCredentials>
            <clientCertificate>
              <certificate findValue="CN=SOAPUIClientCert" storeLocation="LocalMachine"
                storeName="My" x509FindType="FindBySubjectDistinguishedName" />
            </clientCertificate>
            <serviceCertificate findValue="CN=MyWCFServiceCert" storeLocation="LocalMachine"
              storeName="My" x509FindType="FindBySubjectDistinguishedName" />
          </serviceCredentials>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <customBinding>
        <binding name="MyServicesCustomBinding">
          <transactionFlow/>
          <textMessageEncoding messageVersion="Soap11" />
          <security defaultAlgorithmSuite="Basic128Rsa15" allowSerializedSigningTokenOnReply="true"
             authenticationMode="MutualCertificateDuplex"
            requireDerivedKeys="false" securityHeaderLayout="Strict" includeTimestamp="true"
                    messageSecurityVersion="WSSecurity10WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10"
            requireSignatureConfirmation="false">
            <issuedTokenParameters keyType="AsymmetricKey">
              <issuer address=""  binding="customBinding" bindingConfiguration="MyServicesCustomBinding" />
              <issuerMetadata address="">
                <identity>
                  <certificateReference findValue="CN=MyWCFServiceCert" isChainIncluded="false" />
                </identity>
              </issuerMetadata>
            </issuedTokenParameters>
            </security>
         <httpsTransport requireClientCertificate="false"/>
        </binding>
      </customBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="My.Services.ResourceManagementServiceBehavior"
        name="My.Services.ResourceManagementService">
        <endpoint address="" binding="customBinding" bindingConfiguration="MyServicesCustomBinding"
          name="MyBinding" contract="My.Services.IResourceManagementService">
          <!--<identity>
            <dns value="localhost" />
          </identity>-->
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="ResourceManagementService.svc" />
          </baseAddresses>
        </host>
      </service>
    </services>
  </system.serviceModel>

使用上述配置对 WCF 服务进行测试时出现的问题:

“安全策略导出失败。该绑定包含一个 AsymmetricSecurityBindingElement 和一个安全传输绑定元素。不支持此类绑定的策略导出。 ----> System.InvalidOperationException:安全策略导出失败。该绑定包含一个 AsymmetricSecurityBindingElement 和一个安全传输绑定元素。不支持此类绑定的策略导出。 在 System.ServiceModel.Channels.SecurityBindingElement.ExportPolicy(MetadataExporter 导出器,PolicyConversionContext 上下文)

我查看了许多博客和帖子,但没有一个能真正提供帮助。如果我使用“CertificateOverTransport”之类的身份验证模式,它看起来工作正常(至少没有抛出上述错误),但它生成的策略(在 .svc?wsdl 中)与 ESP 所需的策略不匹配。问题似乎是使用带有身份验证模式“MutualCertificateDuplex”的 HTTPS。

我在一些博客中说,如果我们使用公钥基础设施 (PKI),我们不需要使用 HTTPs,但是为了满足我们客户的要求(与他们的政策相匹配),我有什么方法可以配置我的 WCF 服务?

【问题讨论】:

    标签: wcf https x509


    【解决方案1】:

    尝试注释掉ServiceMetadataBehavior部分,它可能会导致生成WSDL策略时出现问题。客户需要将自己配置为相同的设置,但这应该没问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-30
      • 1970-01-01
      • 1970-01-01
      • 2013-01-23
      • 2015-12-18
      相关资源
      最近更新 更多