1

証明書を使用して動作する wcf サービスを作成しました。自己署名証明書を使用しているテストは完璧に機能しますが、証明書が CA によって生成されるサーバーで実行しようとすると、すべてが変更されます。CA を使用してクライアント証明書とサーバー証明書を生成し、その後、サーバー証明書を「Trusted people」フォルダーにエクスポートしました。(両方の証明書を LocalMachine ディレクトリに配置しました)。また、証明書に必要なすべての権限を付与しました。

例外が発生しているクライアント プログラムを実行しているときに問題が発生します。

X.509 証明書 CN=xxxx が信頼できるユーザー ストアにありません。

これが私のサーバー構成です

  <services>
    <service behaviorConfiguration="MyServiceBehavior" name="PoswsService">
     <endpoint address="http://xxxx/PoswsService.svc" binding="wsHttpBinding" bindingConfiguration="MyServiceBinding"
      contract="IPoswsService" />
     <endpoint address="http://xxxx/mex" binding="mexHttpBinding" name="MetadataBinding"
      contract="IMetadataExchange" />
    </service>
   </services>
     <behaviors>
        <serviceBehaviors>
           <behavior name="MyServiceBehavior">
              <serviceCredentials>
                 <clientCertificate>
                    <authentication certificateValidationMode="PeerOrChainTrust" revocationMode="Online"/>
                 </clientCertificate>
                 <serviceCertificate findValue="xxxxxxxxxxxxxxxxxxxxx" storeLocation="LocalMachine"
                    storeName="My" x509FindType="FindBySerialNumber" />
              </serviceCredentials>
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="true" />
           </behavior>
        </serviceBehaviors>
     </behaviors>
    <bindings>
      <wsHttpBinding>
        <binding name="MyServiceBinding">
            <security>
                <message clientCredentialType="Certificate"/>
            </security>
        </binding>
      </wsHttpBinding>
    </bindings>
  </system.serviceModel>

ここにクライアント構成があります

<system.serviceModel>
    <bindings>
        <wsHttpBinding>
            <binding name="WSHttpBinding_IPoswsService" 
                bypassProxyOnLocal="false" transactionFlow="false" >
                <security mode="Message">
                    <transport clientCredentialType="Windows" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="Certificate" negotiateServiceCredential="true"
                        algorithmSuite="Default" />
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://xxxx/PoswsService.svc"
            binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IPoswsService"
            contract="TestService.IPoswsService" name="WSHttpBinding_IPoswsService" behaviorConfiguration="CustomBehavior">
            <identity>
                <certificate encodedValue="long word" />
            </identity>
        </endpoint>
    </client>

  <behaviors>
    <endpointBehaviors>
      <behavior name="CustomBehavior">
        <clientCredentials>
          <clientCertificate findValue="xxxxxxxxxxxxxxxxxxx" x509FindType="FindBySerialNumber" storeLocation="CurrentUser" storeName="My"/>
          <serviceCertificate>
            <authentication certificateValidationMode="PeerTrust"/>
          </serviceCertificate>
        </clientCredentials>
      </behavior>
    </endpointBehaviors>
  </behaviors>
</system.serviceModel>

誰かが私の間違いを知っていましたか?

4

2 に答える 2

-1

私は WCF の経験があまりありませんが、一般的に、信頼できる場所に CA 証明書を配置したいと考えています。クライアントには独自の信頼できる場所が必要であり、CA 証明書もそこに移動する必要があります。これが本番サービスの場合は、クライアントとサーバーの両方で certificateValidationMode を「ChainTrust」に変更する必要があります。これは、CA 証明書に連鎖する証明書を信頼することを意味します。「PeerTrust」は、信頼したい実際の証明書を信頼できる場所に置くだけであることを意味します。このページを見ると参考になるかもしれません。

于 2013-05-14T17:53:28.507 に答える