4

WSHttpBinding を使用して、WCF を使用して自分のマシンでプロセス間通信を行っています。サービスを制限して、現在のマシン上のプロセスのみがサービスを呼び出せるようにしたいと考えています。これどうやってするの?

本質的にこの制限を実行する NetNamedPipesBinding を使用したいと思いますが、これは私のシナリオでは不可能であるため、WSHttpBinding を使用して制限する方法が必要です。NetNamedPipesBinding を使用できない理由は、サービスのクライアントの 1 つが整合性の低いプロセス (保護モードの Internet Explorer) 内で実行されており、整合性の高い名前付きパイプに接続するためのアクセス権がないためです (このような文書化されていないジガリーポーキーの多くは良さそうに見えますが、私は避けたいと思います)。

1 つのオプションは、ここで説明されているように、IP アドレスで制限する IDispatchMessageInspector を追加することです。それが最善のアプローチですか?

更新: このソフトウェアは数百台のマシンに展開されるため、証明書を使用するようなソリューションは、必要以上に手間がかかる可能性があります。

4

1 に答える 1

0

X509 証明書を使用してセキュリティ署名を作成してみてください。そうすれば、ロックとキーを保持できます。他の IP はサービスにアクセスできますが、通信はできません。次のようなことができます。

サービス内:

          <behaviors>
  <serviceBehaviors>
    <behavior name="wsHttpCertificateBehavior">
      <dataContractSerializer maxItemsInObjectGraph="50000"/>
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
      <serviceCredentials>
        <clientCertificate>
          <authentication certificateValidationMode="ChainTrust" revocationMode="NoCheck" />
        </clientCertificate>
        <serviceCertificate findValue="CN=WSE2QuickStartServer" storeLocation="LocalMachine"
          storeName="My" x509FindType="FindBySubjectDistinguishedName" />
      </serviceCredentials>
    </behavior>
    <behavior name="">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>

クライアントで:

    <behaviors>
  <endpointBehaviors>
    <behavior name="wsHttpCertificateBehavior">
      <dataContractSerializer maxItemsInObjectGraph="50000" />
      <clientCredentials>
        <clientCertificate findValue="CN=WSE2QuickStartClient" storeLocation="CurrentUser" storeName="My" x509FindType="FindBySubjectDistinguishedName" />
        <serviceCertificate>
          <authentication certificateValidationMode="ChainTrust" revocationMode="NoCheck" trustedStoreLocation="LocalMachine" />
        </serviceCertificate>
      </clientCredentials>
    </behavior>
  </endpointBehaviors>
</behaviors>

<client>
  <endpoint address="https://localhost/ClientService.svc" behaviorConfiguration="wsHttpCertificateBehavior" binding="wsHttpBinding" bindingConfiguration="ApplicationServicesBinding" contract="GAINABSApplicationServices.Contracts.ServiceContracts.IClientService" name="ClientService">
    <!--<identity>
      <certificateReference storeName="AddressBook" storeLocation="CurrentUser"
        x509FindType="FindBySubjectName" findValue="WSE2QuickStartServer"
        isChainIncluded="true" />
    </identity>-->
  </endpoint>
 </client>

サービスとの通信時に ID に証明書を明示的に使用していることを示すために、オプションでクライアントに Identity タグが必要になる場合があります。お役に立てれば!

于 2011-09-12T17:31:40.883 に答える