WCF Error "Found multiple X.509 certificates using search criteria"

Nirman picture Nirman · Dec 16, 2013 · Viewed 11.2k times · Source

I receive following error when I try accessing a WCF service hosted on our staging server.

"Found multiple X.509 certificates using the following search criteria: StoreName 'My', StoreLocation 'LocalMachine', FindType 'FindBySubjectName', FindValue 'StagingServer001'. Provide a more specific find value."

I try to access the following URL and get above error:

http://stagingserver001/MyService1.svc

Could anyone please guide me how can I find the certificate in the store to delete it? Or what changes I need in configurations of WCF

Please find below the the relevant code taken from web.config of the WCF service

<behaviors>
      <endpointBehaviors>
        <behavior name="endpointCredentialBehavior">
          <clientCredentials>
            <clientCertificate findValue="SPLEBUSSTG02" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
            <serviceCertificate>
              <defaultCertificate findValue="772f3fdf2496c9750be3b0713003b47b15dfde96" storeLocation="LocalMachine" storeName="My" x509FindType="FindByThumbprint" />
              <authentication certificateValidationMode="PeerOrChainTrust" />
            </serviceCertificate>
          </clientCredentials>
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="SecurityBehavior">
          <serviceMetadata httpGetEnabled="True"  />
          <serviceDebug includeExceptionDetailInFaults="false" />
          <serviceCredentials>
            <serviceCertificate findValue="772f3fdf2496c9750be3b0713003b47b15dfde96" storeLocation="LocalMachine" storeName="My" x509FindType="FindByThumbprint" />
            <clientCertificate>
              <certificate findValue="SPLEBUSSTG02" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
              <authentication certificateValidationMode="PeerOrChainTrust" />
            </clientCertificate>
          </serviceCredentials>
        </behavior>
        <behavior>
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
          <!-- 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" />
          <ServiceErrorHandler />
        </behavior>
      </serviceBehaviors>

    </behaviors>

Answer

Yaugen Vlasau picture Yaugen Vlasau · Dec 16, 2013

I think you problem in certificate store. please do the following:

  1. run mmc
  2. menu file/Add Remove Snap-In
  3. from the treeview select certificates, than select radiobox Local computer
  4. Certificates(local computer)/Personal/certificates
  5. look through all certificates listed there. there should be a dublication. (if the duplication is not visible right on the first look, double click on each certificate, go to Detatis tab, find the Subject property) enter image description here

Get rid of duplication if possible. in other case define FindByThumbprint criteria in your config