2010-12-18 8 views
3

私は証明書セキュリティーを使用して私のWCFサービスを設定していましたが、たくさんの記事を見つけましたが、どの記事が簡単なのか判断できません。さらにこれらのコマンドを入力すると、いくつかのツールがVisual Studioのコマンドプロンプトに表示され、一部は表示されません。誰かが私に正確なステップを教えてくれますか、私に素晴らしいリンクを教えてもらえますか?自己署名証明書を使用してWCFセキュリティを実装するにはどうすればよいですか?

ありがとうございます。

答えて

4

これは最も難しい設定です。それ以外の場合は、単にクライアントとサーバーの証明書を作成して証明書をインストールするだけです。私はあなたがそれをする方法を知っていると仮定します。証明書は、信頼できるユーザーストアに置く必要があります。大部分が削除された設定が下に貼り付けられます。私はこれをうまく使いました(あなたは "ここのアドレス"のような値を置き換える必要があるでしょう...)ので、この設定を行ごとにして、あなたが物事を名づけたいものを決めてください。 2つのチュートリアルのが、私はもうリンクを持っていません。

<system.serviceModel> 
<services> 
    <service name="MyService" behaviorConfiguration="MyServiceBehavior"> 
    <endpoint name="MyServiceEndpoint" address="" binding="netTcpBinding" bindingConfiguration="MyServiceBinding" contract="IMyContract"/> 
    <host> 
     <baseAddresses> 
     <add baseAddress="address here"/> 
     </baseAddresses> 
    </host> 
    </service> 
</services> 
<client> 
    <endpoint name="MyClientEndpoint" address="address here" behaviorConfiguration="ClientCertificateBehavior" binding="netTcpBinding" bindingConfiguration="MyClientBinding" contract="IMyContract"> 
    <identity> 
     <dns value="ServerCertificate"/> 
    </identity> 
    </endpoint> 
</client> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="MyServiceBehavior"> 
     <serviceMetadata/> 
     <!--need this for mex to work properly!--> 

     <!-- 
     The serviceCredentials behavior allows you to define a service certificate. 
     A service certificate is used by the service to authenticate itself to its clients and to provide message protection. 
     This configuration references the "localhost" certificate installed during the set up instructions. 
     --> 
     <serviceCredentials> 
     <serviceCertificate findValue="ServerCertificate" storeLocation="CurrentUser" storeName="My" x509FindType="FindBySubjectName"/> 
     <clientCertificate> 
      <!-- 
      Setting the certificateValidationMode to PeerOrChainTrust means that if the certificate 
      is in the user's Trusted People store, then it is trusted without performing a 
      validation of the certificate's issuer chain. This setting is used here for convenience so that the 
      sample can be run without having certificates issued by a certificate authority (CA). 
      This setting is less secure than the default, ChainTrust. The security implications of this 
      setting should be carefully considered before using PeerOrChainTrust in production code. 
      --> 
      <authentication certificateValidationMode="PeerOrChainTrust" trustedStoreLocation="CurrentUser"/> 
     </clientCertificate> 
     </serviceCredentials> 
    </behavior> 
    </serviceBehaviors> 
    <endpointBehaviors> 
    <behavior name="ClientCertificateBehavior"> 
     <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 
     <!-- 
     The clientCredentials behavior allows you to define a certificate to present to a service. 
     A certificate is used by a client to authenticate itself to the service and provide message integrity. 
     This configuration references the "client.com" certificate installed during the setup instructions. 
     --> 
     <clientCredentials> 
     <clientCertificate findValue="WFCClient" storeLocation="CurrentUser" storeName="My" x509FindType="FindBySubjectName"/> 
     <serviceCertificate> 
      <!-- 
      Setting the certificateValidationMode to PeerOrChainTrust means that if the certificate 
      is in the user's Trusted People store, then it is trusted without performing a 
      validation of the certificate's issuer chain. This setting is used here for convenience so that the 
      sample can be run without having certificates issued by a certificate authority (CA). 
      This setting is less secure than the default, ChainTrust. The security implications of this 
      setting should be carefully considered before using PeerOrChainTrust in production code. 
      --> 
      <authentication certificateValidationMode="PeerOrChainTrust" trustedStoreLocation="CurrentUser"/> 
     </serviceCertificate> 
     </clientCredentials> 
    </behavior> 
    </endpointBehaviors> 
</behaviors> 
<bindings> 
    <netTcpBinding> 
    <binding name="MyClientBinding" maxConnections="25000" listenBacklog="25000" portSharingEnabled="false" closeTimeout="00:05:00" openTimeout="00:05:00" sendTimeout="24:11:30" transferMode="Buffered" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2097152000" maxReceivedMessageSize="2097152000" maxBufferPoolSize="2097152000"> 
     <readerQuotas maxStringContentLength="2000000000" maxArrayLength="2000000000" maxDepth="2000000000" maxBytesPerRead="2000000000" maxNameTableCharCount="2000000000"/> 
     <security mode="Transport"> 
     <transport clientCredentialType="Certificate" protectionLevel="EncryptAndSign"/> 
     <message clientCredentialType="Certificate"/> 
     </security> 
    </binding> 
    <binding name="MyServiceBinding" maxConnections="25000" listenBacklog="25000" portSharingEnabled="false" closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="24:12:35" transferMode="Buffered" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="10485760" maxReceivedMessageSize="10485760" maxBufferPoolSize="104857600"> 
     <readerQuotas maxStringContentLength="2000000000" maxArrayLength="2000000000" maxDepth="2000000000" maxBytesPerRead="2000000000" maxNameTableCharCount="2000000000"/> 
     <security> 
     <transport clientCredentialType="Certificate"/> 
     </security> 
    </binding> 
    </netTcpBinding> 
</bindings> 

関連する問題