Bug 54510 - X509Certificate2Collection.Import() can't consume p7b file
Summary: X509Certificate2Collection.Import() can't consume p7b file
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Security (show other bugs)
Version: 4.9.X
Hardware: PC Windows
: --- normal
Target Milestone: Future Release
Assignee: Bugzilla
Depends on:
Reported: 2017-04-05 18:01 UTC by Alex Orlov
Modified: 2017-10-06 12:36 UTC (History)
2 users (show)

See Also:
Is this bug a regression?: ---
Last known good build:

p7b file sample (1.00 KB, application/x-pkcs7-certificates)
2017-04-05 18:01 UTC, Alex Orlov

Description Alex Orlov 2017-04-05 18:01:08 UTC
Created attachment 21223 [details]
p7b file sample

// p7b_path denotes p7b filename
X509Certificate2Collection certCollection = new X509Certificate2Collection();

This code results in CryptographicException (Unable to decode certificate), no matter which p7b file is tried.

p7b files are created by Windows wizard (open a .cer file and export certificate chain). The originating .cer file is loaded just fine:

// cer_path denotes cer filename
x509Cer = new X509Certificate2(cer_path);

Trying this .p7b and .cer thing in Android Emulator (installed with Xamarin for Visual Studio). The product is up-to-date.

The same p7b file and the same code runs just fine in .NET Core 1.0 on Windows. Running on the legacy .NET Framework 2.0 is fine either. The certificate gets extracted successfully.

Tried this with several p7b files, no difference.
Comment 1 Marek Safar 2017-10-06 12:36:56 UTC
It works fine for me with Mono 5.4

Note You need to log in before you can comment on or make changes to this bug.