0

メッセージ セキュリティが有効になっている 2 つのターゲット サービス エンドポイントを含むプロジェクトに WCF ルーティングを導入しようとすると、問題が発生します。(署名のみ - 暗号化なし) どちらか一方のサービスに向ける単純なアクション ベースのフィルターを 2 つ設定しました。

クライアントから RoutingService を呼び出すと、トレース ログに次のエラー メッセージが表示されます。

The 'Body', 'http://www.w3.org/2003/05/soap-envelope' required message part was not encrypted.

サービス インターフェイスに ProtectionLevel.Sign を設定したので、これが問題である理由を理解するのに苦労しています。

[ServiceContract(Namespace = "http://helloservice.adam.com/services/v1.0", ProtectionLevel = ProtectionLevel.Sign)]
public interface IHelloAService
{
    [OperationContract(Action = "http://helloservice.adam.com/services/v1.0/helloa", ProtectionLevel = ProtectionLevel.Sign)]
    string SayHello(string name);
}

誰でも提供できるヘルプは大歓迎です。

WCF サービス プロジェクトの構成

サービス

<services>
  <service name="System.ServiceModel.Routing.RoutingService" behaviorConfiguration="RoutingSecureBehavior" >

    <endpoint binding="customBinding" bindingConfiguration="HTTPSCustomBinding" 
              contract="System.ServiceModel.Routing.ISimplexDatagramRouter" 
              name="RoutingServiceEndpoint" />

  </service>

  <service name="WCF.Services.HelloAService" behaviorConfiguration="SecureServiceBehavior">
    <endpoint binding="customBinding" bindingConfiguration="HTTPSCustomBinding" 
              contract="WCF.Services.IHelloAService" />
  </service>

  <service name="WCF.Services.HelloBService" behaviorConfiguration="SecureServiceBehavior">
    <endpoint binding="customBinding" bindingConfiguration="HTTPSCustomBinding"   
              contract="WCF.Services.IHelloBService" />
  </service>

</services>

バインディング

  <customBinding>
    <binding name="HTTPSCustomBinding">
      <textMessageEncoding messageVersion="Soap12WSAddressing10" writeEncoding="utf-8" />
      <security allowSerializedSigningTokenOnReply="true"
                authenticationMode="MutualCertificateDuplex"
                messageSecurityVersion="WSSecurity11WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10"
                messageProtectionOrder="SignBeforeEncrypt" />
      <httpsTransport/>
    </binding>
  </customBinding>

サービスの振る舞い

  <serviceBehaviors>

    <behavior name="SecureServiceBehavior">
      <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
      <serviceCredentials>
        <clientCertificate>
          <authentication certificateValidationMode="ChainTrust" revocationMode="NoCheck" />
        </clientCertificate>
        <serviceCertificate findValue="service.adam.com" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
      </serviceCredentials>
      <serviceThrottling maxConcurrentCalls="50" maxConcurrentInstances="50" />
    </behavior>

    <behavior name="RoutingSecureBehavior">
      <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
      <serviceCredentials>
        <clientCertificate>
          <authentication certificateValidationMode="ChainTrust" revocationMode="NoCheck" />
        </clientCertificate>
        <serviceCertificate findValue="service.adam.com" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
      </serviceCredentials>
      <serviceThrottling maxConcurrentCalls="50" maxConcurrentInstances="50" />
      <routing filterTableName="MyFilterTable" routeOnHeadersOnly="True" />
    </behavior>

  </serviceBehaviors>

フィルター

<routing>
  <filters>

    <filter name="HelloAAction" filterType="Action" filterData="http://helloservice.adam.com/services/v1.0/helloa" />
    <filter name="HelloBAction" filterType="Action" filterData="http://helloservice.adam.com/services/v1.0/hellob" />

  </filters>

  <filterTables>
    <filterTable name="MyFilterTable">
      <add filterName="HelloAAction" endpointName="HelloA" priority="100" />
      <add filterName="HelloBAction" endpointName="HelloB" priority="100" />
    </filterTable>
  </filterTables>

</routing>    

サービス側クライアント

<client>

  <endpoint name="HelloA" binding="customBinding" bindingConfiguration="HTTPSCustomBinding" behaviorConfiguration="Internal_SecureClientBehavior" contract="*" />
  <endpoint name="HelloB" binding="customBinding" bindingConfiguration="HTTPSCustomBinding" behaviorConfiguration="Internal_SecureClientBehavior" contract="*" />

</client>

エンドポイントの動作

  <endpointBehaviors>

    <behavior name="Internal_SecureClientBehavior">
      <clientCredentials>
        <clientCertificate findValue="service.adam.com" x509FindType="FindBySubjectName" storeLocation="LocalMachine" storeName="My" />
        <serviceCertificate>
          <authentication revocationMode="NoCheck" certificateValidationMode="ChainTrust" />
          <defaultCertificate findValue="service.adam.com" x509FindType="FindBySubjectName" storeLocation="LocalMachine" storeName="My" />
        </serviceCertificate>
      </clientCredentials>
    </behavior>

  </endpointBehaviors>

WCF クライアント プロジェクト構成

クライアント側クライアント

<client>    
  <endpoint name="ServiceProxy"
            address="https://services.adam.com/ServiceProxy.svc"
            binding="customBinding" bindingConfiguration="HTTPSCustomBinding"
            behaviorConfiguration="SecureClientBehavior"
            contract="WCF.Services.IHelloAService">
    <identity>
      <dns value="service.adam.com" />
    </identity>
  </endpoint>
</client>

バインディング

  <customBinding>
    <binding name="HTTPSCustomBinding">
      <textMessageEncoding messageVersion="Default" writeEncoding="utf-8" />

      <security allowSerializedSigningTokenOnReply="true" authenticationMode="MutualCertificateDuplex"
                messageProtectionOrder="SignBeforeEncrypt"
                messageSecurityVersion="WSSecurity11WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10" />
      <httpsTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"
                      maxPendingAccepts="1" />
    </binding>
  </customBinding>

行動

  <endpointBehaviors>
    <behavior name="SecureClientBehavior">
      <clientCredentials>
        <clientCertificate findValue="client.adam.com" x509FindType="FindBySubjectName"
                           storeLocation="LocalMachine" storeName="My" />
        <serviceCertificate>
          <authentication revocationMode="NoCheck" certificateValidationMode="ChainTrust" />
          <defaultCertificate findValue="service.adam.com" x509FindType="FindBySubjectName"
                              storeLocation="LocalMachine" storeName="My" />
        </serviceCertificate>
      </clientCredentials>
    </behavior>
  </endpointBehaviors>
4

0 に答える 0