2012-07-14 9 views
11

問題:WCFのX.509証明書はありますか?

私は1台のマシン上でこのプログラムを開発しています。

サービスは、開発サーバーでは正常に動作しますが、私はIISでサービスをホストしようとすると、それは私にエラーを与えている:

次の検索基準を使用してX.509証明書を見つけることができません。StoreNameを " My '、StoreLocation' CurrentUser '、FindType' FindBySubjectName '、FindValue' WCFServer 'です。

だから私はこの問題を解決することができますとにかくありますか? 私は

http://www.codeproject.com/KB/WCF/9StepsWCF.aspx

証明書の作成

makecert.exe -sr CurrentUser -ss My -a sha1 -n CN=WCfServer -sky exchange -pe 
makecert.exe -sr CurrentUser -ss My -a sha1 -n CN=WcfClient -sky exchange -pe 

証明書は、個人的に存在し、信頼されたユーザーは、MMC内のフォルダ

サービスは数を受け入れ、1つの機能を持っているから、このコードをしようとしています文字列を返し、正常に動作します

これは私のサービスのweb.configです:

<system.serviceModel> 
    <bindings> 
     <wsHttpBinding> 
     <binding name="wsHttpEndpointBinding"> 
      <security> 
      <message clientCredentialType="Certificate" /> 
      </security> 
     </binding> 
     </wsHttpBinding> 
    </bindings> 
    <services> 
     <service name="WCFServiceCertificate.Service1" behaviorConfiguration="WCFServiceCertificate.Service1Behavior"> 
     <!-- Service Endpoints --> 
     <endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsHttpEndpointBinding" contract="WCFServiceCertificate.IService1"> 
      <!-- 
       Upon deployment, the following identity element should be removed or replaced to reflect the 
       identity under which the deployed service runs. If removed, WCF will infer an appropriate identity 
       automatically. 
      --> 
      <!--<identity> 
      <dns value="localhost"/> 
      </identity>--> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="WCFServiceCertificate.Service1Behavior"> 
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
      <serviceMetadata httpGetEnabled="true"/> 
      <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
      <serviceDebug includeExceptionDetailInFaults="false"/> 
      <serviceCredentials> 
      <clientCertificate> 
       <authentication certificateValidationMode="PeerTrust"/> 
      </clientCertificate> 
      <serviceCertificate findValue="WcfServer" 
           storeLocation="CurrentUser" 
           storeName="My" 
           x509FindType="FindBySubjectName" /> 
      </serviceCredentials> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 

これは私のクライアントのコンフィグ

<system.serviceModel> 
       <bindings> 
    <wsHttpBinding> 
    <binding name="WSHttpBinding_IService1" closeTimeout="00:01:00" 
    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
    bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
    maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" 
    textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"> 
    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
     maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
    <reliableSession ordered="true" inactivityTimeout="00:10:00" 
     enabled="false" /> 
    <security mode="Message"> 
     <transport clientCredentialType="Windows" proxyCredentialType="None" 
     realm="" /> 
     <message clientCredentialType="Certificate" negotiateServiceCredential="true" 
     algorithmSuite="Default" establishSecurityContext="true" /> 
    </security> 
    </binding> 
    </wsHttpBinding> 
    </bindings> 
       <client> 
    <endpoint address="http://localhost:1387/Service1.svc" behaviorConfiguration="CustomBehavior" 
    binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService1" 
    contract="ServiceReference1.IService1" name="WSHttpBinding_IService1"> 
    <identity> 
    <certificate encodedValue="AwAAAAEAAAAUAAAA9YoGKvsMLFkeO1WjaCLReQuz1ysgAAAAAQAAALUBAAAwggGxMIIBX6ADAgECAhDDvb3bnmzhsERpNTWEBYQXMAkGBSsOAwIdBQAwFjEUMBIGA1UEAxMLUm9vdCBBZ2VuY3kwHhcNMTEwMzA0MDcwNzU3WhcNMzkxMjMxMjM1OTU5WjAUMRIwEAYDVQQDEwlXY2ZTZXJ2ZXIwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAM9e4DwCDYJ4l6myt1QadHzXoqCH2wa1aUjiab1aK/7d/1LZ00KfPJw8kKB358serjEi9SMg0UeyGtl0+byJ8PqShfv4MUTHZcPaWy99vHaYHwH7T9hVwY5RANBWyFy6nf1rXDh/cB2qm0Q/xN5xElOtheFqUoL8Ua6fcP33BAWPAgMBAAGjSzBJMEcGA1UdAQRAMD6AEBLkCS0GHR1PAI1hIdwWZGOhGDAWMRQwEgYDVQQDEwtSb290IEFnZW5jeYIQBjdsAKoAZIoRz7jUqlw19DAJBgUrDgMCHQUAA0EAKlaHJQNdC9VgPuHlVuniQJd+fHoVOU62nl374iXYdQus5KDgKz9RHWAtjhpToBB4sOXOnwTkJfcyJWBf6J14Mw==" /> 
    </identity> 
    </endpoint> 
    </client> 
       <behaviors> 
         <endpointBehaviors> 
           <behavior name="CustomBehavior"> 
             <clientCredentials> 
               <clientCertificate findValue="WcfClient" 
           x509FindType="FindBySubjectName" 
           storeLocation="CurrentUser" 
           storeName="My"/> 
               <serviceCertificate> 
                 <authentication certificateValidationMode="PeerTrust"/> 
               </serviceCertificate> 
             </clientCredentials> 
           </behavior> 
         </endpointBehaviors> 
       </behaviors> 
     </system.serviceModel> 

と私はすべてが問題なく正常に動作し実行した場合、単純に今、この

Service1Client obj = new Service1Client(); 
      Response.Write(obj.GetData(12)); 

を使用してクライアント側でサービスを呼び出すことです。あなたがサービスを提供することができたよう

は、開発サーバーで実行されています。

しかし、私は、IISのサービスをホストしようとすると、それは

は、以下の検索基準を使用してX.509証明書を見つけることができないことを私にエラーを与える: StoreNameを「マイ」、StoreLocation「CurrentUserに」 FindType 'FindBySubjectName'、FindValue 'WCFServer'。

だから私はこの問題を解決することができますとにかくありますか?

答えて

13

x0n上記のとおり、カッシーニはあなたの現在のユーザーとして実行されますが、IISはIUSRとして実行されます。LOCALMACHINE \個人(LOCALMACHINE \マイ)に、秘密鍵を使用して、証明書をインポートし、そしてこのことから、あなたのサービスの設定を変更します。これに

 <serviceCertificate findValue="WcfServer" 
          storeLocation="CurrentUser" 
          storeName="My" 
          x509FindType="FindBySubjectName" /> 

 <serviceCertificate findValue="WcfServer" 
          storeLocation="LocalMachine" 
          storeName="My" 
          x509FindType="FindBySubjectName" /> 
0

明らかに証明書が設定された場所で発見されていません。サービスを実行するためにどのユーザーを使用しているかを確認します。サービスがローカルシステムアカウントまたはローカルサービスアカウントまたはIISユーザーで実行されていて、別のユーザーとして証明書をインストールしたとしますか? MMCでサービススナップインを追加して、サービス(現在のユーザーではない)に使用しているサービスアカウントまたはその他のアカウントの証明書を確認します。

+0

感謝。私はサーバー上で使用しましたが、クライアントはサービスエラーを受け取ります: –

+0

クライアント証明書は提供されていません。 ClientCredentialsでクライアント証明書を指定します。 –

1

すべてのユーザーがコンピュータストアを使用できるようにするために、コンピュータストアの証明書を "My"にインストールします。あなたは現在のユーザーのために "My"にインストールされています。開発サーバーは現在のユーザーとして実行されるので、それが機能します。

1

あなたは多分設定する必要がありますクライアントでの証明書の名前を意味するDNS値、> endopoint> indentity(それは以下のコードに記載されているように)あなたが示唆

<client> 
     <endpoint address="http://localhost/FrontPMWebServiceSetup111/FpmService.svc" 
      binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService" 
      contract="FPMServiceReference.IService" name="WSHttpBinding_IService"> 
      <identity> 
      <dns value="WCfServer" /> 
      </identity> 
     </endpoint> 
     </client> 
関連する問題