I am using the below code to configure SSL cert in C# web API. The issue is I am finding the SSL cert using the serial number and every time when the SSL cert is reissued by Infra I have to update the cert serial number in the application config. Is there any cert property that remains the same after reissue?
X509Store store = new X509Store(StoreLocation.LocalMachine);
store.Open(OpenFlags.ReadOnly);
X509Certificate2Collection certificates = store.Certificates.Find(
X509FindType.FindBySerialNumber,
sslCertificateSerialNumber,
false);
'sslCertificateSerialNumber' is coming from the config file
You can use findBySubjectName it's more useful. If you have multiple subjects you can act like this: