I had a certificate installed on:
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:
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?
The certificates in the intermediate store are used for certificate chain validation purpose. If your certificate is a self signed certificate then its issuer need to be present in trusted root authority for the certificate validation to succeed.
Just placing it in the intermediate certificate authority would not be enough.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With