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 ()
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)

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

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

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