0

When trying to create a new certificate from a PKCS#7 (.p7b)-file I get the following exception: System.Security.Cryptography.CryptographicException: 'Cannot find object or property'

I get the same error if I read from file or byte array. I can create X509Certificate2 with .pem or .p12 files this way without a problem. Why is this happening?

new X509Certificate2(path);
new X509Certificate2(byteArray);
Ogglas
  • 62,132
  • 37
  • 328
  • 418
  • 2
    In order to import PKCS#7 object you need to use `X509Certificate2Collection.Import` method. – Crypt32 May 23 '17 at 20:10
  • @Crypt32 Thanks! – Ogglas May 23 '17 at 20:25
  • Possible duplicate of ['Cannot find the requested object' exception while creating X509Certificate2 from string](https://stackoverflow.com/questions/44053426/cannot-find-the-requested-object-exception-while-creating-x509certificate2-fro) – bartonjs May 23 '17 at 22:04

1 Answers1

-1

we had a similar error and Cryp32's suggestion to use X509Certificate2Collection.Import method worked well. Please mark it as as valid solution to the issue if it worked in your case as well.