I had a certificate installed on:
- Certificates (Local Computer)
- Trusted root Certification Authorities
- Certificates
- Trusted root Certification Authorities
And this code got the certificate as valid.
X509Store certStore = new X509Store(StoreName.CertificateAuthority, StoreLocation.LocalMachine);
certStore.Open(OpenFlags.OpenExistingOnly | OpenFlags.ReadOnly);
try {
var oAuthRootCertificateList = certStore.Certificates.Find(findType, findValue, true);
oauthRootCertificate = oAuthRootCertificateList[0];
} catch (Exception ex) {
Trace.TraceError(ex.Message);
} finally {
certStore.Close();
}
*(findType and findValue are set previously in the code)
All was ok and the code was fine.
Now I have deleted the certificate from 'trusted root certification authorities' and installed on:
- Certificates (Local Computer)
- Intermediate Certification Authorities
- Certificates
- Intermediate Certification Authorities
because Azure doesn't let me to deploy the certificate on the Trusted Root branch.
And now, the code is failing. I must to change the last parameter (validOnly) from true
to false
to get it to run.
You can see the help for the Find
method here.
Any idea why is it not running and how I can solve it?