Take only first certificate found

143 Views Asked by At

Having a behaviour for a endpoint, I specified a serviceCertificate to be used. Everything works fine, but every year we get a new certificate on our servers while the old ones are being left undeleted.

This results in 2 valid certificates (overlapping few days in validity period), both with the same name. When having 2 certificates with the same name, using the service throws an error:

The exception message is: Found multiple X.509 certificates using the following search criteria: StoreName 'My', StoreLocation 'LocalMachine', FindType 'FindBySubjectName', FindValue 'CertName'. Provide a more specific find value

<behaviors>
  <serviceBehaviors>
    <behavior name="serviceBehaviour">
      <serviceCredentials>
        <serviceCertificate findValue="CertName" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName"  />
      </serviceCredentials>
    </behavior>
  </serviceBehaviors>
</behaviors>

I know how to solve this problem for now by deleting the old certificate, but I found no way to solve this for long term, i.e. taking always the first valid certificate.

Is there any way to specify to take one certificate, regardless of the number of available ones that match? I don't want to modify our config files everytime we get a certifcate renewed.

0

There are 0 best solutions below