I have a problem using the X509Store.Certificates.Find function when running my wcf service as LocalSystem.
The StoreLocation is 'LocalMachine' and the StoreName is 'My'.
When running my service as an administrator this function has no problems of finding the requested certificate.
Code i use:
X509Certificate2Collection collection = store.Certificates.Find(findType, findValue, true);
As mentioned before: running the windows service as administrator works fine, as LocalSystem it does not.
I'm not getting any errors, the new collection is just empty, but in both cases store.Certificates contains the requested certificate.
When i use the following code it works fine.
foreach (X509Certificate2 certificate in store.Certificates)
{
if (certificate.Subject == findValue)
//do stuff
}
Can someone explain me why the Certificates.Find function is not working properly?