2016-04-07 10 views
0

opensslを使用してカスタム認証局(CA)を作成しました。それから、私は以前のものとIISからのリクエストを使用して証明書を作成しました。だから私は証明書のチェーンを持っています。その後、私はWCFサービスに2番目のものをバインドしました。次に、クライアントで私のCA証明書を信頼されたルート証明機関にインストールして、私のカスタム証明書を認識できるようにしました。 私のWCFサービスは、現在、単純なhttp接続で実行されています。 サーバー側:WCFサービスとカスタムCA

<system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
      <behavior name="SyncWcfServices.MainServiceBehavior"> 
       <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /> 
       <serviceDebug includeExceptionDetailInFaults="true" /> 
      </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <bindings> 
     <wsHttpBinding> 
      <binding name="ExtendedMaxSize" maxReceivedMessageSize="2147483647"> 
       <security mode="None"> 
        <transport clientCredentialType="None"></transport> 
       </security> 
      </binding> 
     </wsHttpBinding> 
    </bindings> 
    <services> 
     <service name="SyncWcfServices.MainService" behaviorConfiguration="SyncWcfServices.MainServiceBehavior"> 
      <endpoint address="/syncService.svc" binding="wsHttpBinding" bindingConfiguration="ExtendedMaxSize" contract="SyncWcfServices.IMainService"></endpoint> 
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint> 
     </service> 
    </services> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 
</system.serviceModel> 

クライアント側:

<system.serviceModel> 
    <bindings> 
     <wsHttpBinding> 
      <binding name="WSHttpBinding_IMainService" maxReceivedMessageSize="2147483647" sendTimeout="00:10:00"> 
       <security mode="None" /> 
      </binding> 
     </wsHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost/SyncService/SyncService.svc" 
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMainService" 
contract="SyncServiceReference.IMainService" name="WSHttpBinding_IMainService" /> 
    </client> 
</system.serviceModel> 

ので、私はSSL接続をサポートするために、この設定を変更する必要があります。私はそれを行う方法を多くの記事を読んだことがありますが、常に2ウェイ証明書のチェックを使用して、サーバーはクライアント証明書をチェックし、クライアントはサーバー証明書をチェックする必要があります。しかし、私はクライアントが私がインストールしたCAを使用してサーバ証明書をチェックしたいだけです。そして、サーバーは以前と同じように通常の認証情報(ユーザー名、パスワード)で確認します。私はセキュリティモードを両側でトランスポートに、サーバーmexエンドポイントをmexHttpsBindingに変更しなければならないと思いますが、次に何をすればよいですか?それを解決するのを手伝ってください。 ありがとうございました!

答えて

0

最後に正しい方法を見つけました。そこで、サーバ側:

<system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
      <behavior name="SyncWcfServices.MainServiceBehavior"> 
       <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /> 
       <serviceDebug includeExceptionDetailInFaults="true" /> 
       <serviceCredentials> 
       <serviceCertificate 
        findValue = "*.mydomain.com" 
        storeLocation = "LocalMachine" 
        storeName = "My" 
        x509FindType = "FindBySubjectName" 
        /> 
       </serviceCredentials> 
      </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <bindings> 
     <wsHttpBinding> 
      <binding name="ExtendedMaxSize" maxReceivedMessageSize="2147483647"> 
       <security mode="Transport"> 
        <transport clientCredentialType="None"></transport> 
       </security> 
      </binding> 
     </wsHttpBinding> 
    </bindings> 
    <services> 
     <service name="SyncWcfServices.MainService" behaviorConfiguration="SyncWcfServices.MainServiceBehavior"> 
      <endpoint address="" binding="wsHttpBinding" bindingConfiguration="ExtendedMaxSize" contract="SyncWcfServices.IMainService"></endpoint> 
      <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"></endpoint> 
      <host> 
       <baseAddresses> 
        <add baseAddress="http://localhost:8095/Design_Time_Addresses/SyncWcfServices/MainService/" /> 
       </baseAddresses> 
      </host> 
     </service> 
    </services> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 
</system.serviceModel> 

クライアント側:

<system.serviceModel> 
    <behaviors> 
     <endpointBehaviors> 
      <behavior name = "ServiceCertificate"> 
       <clientCredentials> 
        <serviceCertificate> 
         <authentication certificateValidationMode = "ChainTrust"/> 
        </serviceCertificate> 
       </clientCredentials> 
      </behavior> 
     </endpointBehaviors> 
    </behaviors> 
    <bindings> 
     <wsHttpBinding> 
      <binding name="ExtendedMaxSize" maxReceivedMessageSize="2147483647"> 
       <security mode="Transport"> 
        <transport clientCredentialType="None"></transport> 
       </security> 
      </binding> 
     </wsHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="https://localhost/SyncService/SyncService.svc" 
     binding="wsHttpBinding" bindingConfiguration="ExtendedMaxSize" 
     behaviorConfiguration = "ServiceCertificate" 
     contract="SyncServiceReference.IMainService" name="WSHttpBinding_IMainService"> 
     </endpoint>    
    </client> 
</system.serviceModel> 

はそれが誰かを助けることを願っています! また、Juval Lowy著「Programming WCF Services」(第4版)& Michael Montgomeryもご覧ください。それは素晴らしい本です!

関連する問題