0

私がやろうとしていることがサポートされているかどうかについて、決定的な答えを探しています。

基本的に、WCF を使用して大きな MTOM 添付ファイル (200 Mb) をストリーミングしていますが、これは問題なく動作します。サービスのセキュリティ要件は、HTTPS と証明書ベースの認証を使用することです。問題なく HTTPS 経由でサービスを実行できますが、IIS を「クライアント証明書を受け入れる」または「クライアント証明書を要求する」に設定すると (コードに変更はありません)、次のエラーがスローされます (ただし、添付ファイルが解決された場合のみ)。 80Mb程度):

The socket connection was aborted. 
This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. 
Local socket timeout was '00:30:00'.

いくつかのリソースを見つけました。申し訳ありませんが、現在それらを見つけることができません。これは、受信メッセージがデジタル署名されていないか、メッセージ コンテンツのストリーミングの性質のために検証されていないという事実におそらく関連していることを示しています。サービスは証明書を検証するためにメッセージの内容全体をハッシュする必要があると思いますが、検証が行われようとしている間、メッセージの一部が転送中であるため、これは達成できません。

本文が単一の Stream 要素であり、他の要素がヘッダー内に含まれるように、メッセージ コントラクトをセットアップしました。

   <MessageContract()>
Public Class StreamAttachmentRequest

    <MessageHeader(MustUnderstand:=True)>
    Public Property AttachmentName As String

    <MessageBodyMember(Order:=1)>
    Public Property Attachment As Stream

End Class

サービス構成は次のようになります。

<system.serviceModel>

<!-- BINDING -->
<bindings>
<basicHttpBinding>
  <binding name="TestCaseBasicBinding"
           messageEncoding="Mtom"
           transferMode="StreamedRequest"
           maxReceivedMessageSize="2147483647"
           closeTimeout="00:30:00"
           openTimeout="00:30:00"
           receiveTimeout="00:30:00"
           sendTimeout="00:30:00">
    <security mode="Transport">
      <transport clientCredentialType="None"></transport>
    </security>
    <readerQuotas maxDepth="32"
                      maxStringContentLength="8192"
                      maxArrayLength="16384"
                      maxBytesPerRead="4096"
                      maxNameTableCharCount="16384" />
  </binding>
</basicHttpBinding>
</bindings>

<!-- BEHAVIORS -->
<behaviors>
  <serviceBehaviors>

    <!-- TEST CASE SECURE BEHAVIOR -->
    <behavior name="TestCaseSecureBehavior">
      <serviceMetadata httpsGetEnabled="true" httpGetEnabled="false" />
      <serviceDebug includeExceptionDetailInFaults="true"/>
      <serviceCredentials>
        <serviceCertificate
            storeLocation="LocalMachine"
            storeName="My"
            findValue="DistinguishedNameOfCert"
            x509FindType="FindBySubjectDistinguishedName" />
        <clientCertificate>
          <authentication certificateValidationMode="ChainTrust"/>
        </clientCertificate>
      </serviceCredentials>
    </behavior>

  </serviceBehaviors>
</behaviors>

<!-- SERVICES -->
<services>
  <service name="StreamingMutualAuthTestCase.Web.Service.TestCaseServiceImplementation" 
           behaviorConfiguration="TestCaseSecureBehavior">
    <!-- SERVICE -->
    <endpoint address=""
              binding="basicHttpBinding"
              bindingConfiguration="TestCaseBasicBinding"
              contract="StreamingMutualAuthTestCase.Web.Service.ITestCaseService" />

    <endpoint contract="IMetadataExchange" binding="mexHttpsBinding" address="mex" />

  </service>
</services>    

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />

クライアント構成は次のようになります。

 <system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_ITestCaseService" closeTimeout="00:30:00"
                openTimeout="00:30:00" receiveTimeout="00:30:00" sendTimeout="00:30:00"
                maxReceivedMessageSize="2147483647" messageEncoding="Mtom"
                transferMode="Streamed">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <security mode="Transport">
                    <transport clientCredentialType="Certificate" realm="" />
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>

  <!-- BEHAVIORS -->
  <behaviors>
    <endpointBehaviors>
      <behavior name="SecureClientBehavior">
        <clientCredentials>
          <clientCertificate
            storeLocation="LocalMachine"
            storeName="My"
            findValue="DistinguishedNameOfCert"
            x509FindType="FindBySubjectDistinguishedName"/>
          <serviceCertificate>
            <authentication certificateValidationMode="ChainTrust"/>
          </serviceCertificate>
        </clientCredentials>
      </behavior>
    </endpointBehaviors>
  </behaviors>

    <client>
        <endpoint address="https://test7/TestCaseService/TestCaseService.svc" 
                  binding="basicHttpBinding" 
                  bindingConfiguration="BasicHttpBinding_ITestCaseService"
                  contract="TestCaseService.ITestCaseService" 
                  name="BasicHttpBinding_ITestCaseService" 
                  behaviorConfiguration="SecureClientBehavior"/>
    </client>
</system.serviceModel>

繰り返しますが、IIS Client Certs を Accept または Require に設定するまでは問題なく機能します。

また、IIS ログに 413 エラーがあります...

2011-08-18 15:00:06 W3SVC1 10.39.8.111 POST /TestCaseService/TestCaseService.svc - 443 - 10.75.13.81 - - - test7 413 0 0

この問題を回避するために、ファイル アップロード サービスに加えて認証サービスを設計済みです。しかし、私がやろうとしていることが「できる」かどうかを知りたいのです。

どうもありがとう - パトリック

4

1 に答える 1

2

IIS でクライアント証明書を有効にする場合は、サービス (およびクライアント) に対して同じことを行う必要があります。

<security mode="Transport">
  <transport clientCredentialType="Certificate" />
</security>

クライアントはプロキシに証明書を提供する必要があります。

yourProxy.ClientCredentials.ClientCertificate.SetCertificate(...);

また、サーバーはこれらの証明書を信頼する必要があるため、クライアント証明書は、サーバーが信頼する証明機関によって発行されるか、サーバー上の LocalMachine\Trusted people ストアに直接インストールする必要があります。

WCF エンドポイントは「クライアント証明書を受け入れる」をサポートしていません。クライアント証明書を使用するかどうかを選択する必要があります。

于 2011-08-17T14:57:08.480 に答える