Method envelopedData Load randomly does not load the certificate associated with the file that it is encrypted

0 votes
asked Oct 12 by michalis.viglakis (200 points)

a: For specific certificate which has private key, the method loads the recipient and the certificate and property hasPriveteKey is true.

b: For another certificate which has private key, the method loads the recipient but not the certificate and property hasPriveteKey is false.

Both certificates are set for all purposes.

What are the cases for case b?

Thanks

commented Oct 12 by michalis.viglakis (200 points)
Fyi, passing Certificate finder to the envelopedata object and return from my Find implementation the correct certificate is ok.

1 Answer

0 votes
answered Oct 12 by Lukas Matyska (47,230 points)

When loading EnvelopedData the certificate is searched for in CertificateStoreName.My, CertificateStoreName.TrustedPeople and CertificateStoreName.AddressBook certificate stores (based on SubjectIdentifier.Type).

Is it possible that you do not have the certificate in any of those certificate stores?

Or is it possible that you have the certificate without key in one of those certificate stores?

If you post here your certificate finder implementation, we can spot some difference.

commented Oct 13 by michalis.viglakis (200 points)
edited Oct 15 by michalis.viglakis
Thank yiu for the answer, i have all my certificates imported in trusted cas local machine. I guess it should find none. But it finds some of them. But implementing my cert finder i search specific store so it works.
...