Bug 10645 - When building for 4.3 target, X509Certificate2 construction fails in new version
Summary: When building for 4.3 target, X509Certificate2 construction fails in new version
Status: RESOLVED INVALID
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 6.2.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-02-25 11:17 UTC by Chris Hatton
Modified: 2013-02-28 11:05 UTC (History)
2 users (show)

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

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 Developer Community or GitHub 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:
Status:
RESOLVED INVALID

Description Chris Hatton 2013-02-25 11:17:52 UTC
In the newly released, specified version of Xamarin Studio, constructing an X509 Certificate now fails when we target iOS 4.3. We have to target this version for client support - and in the previous version (most updated version of MonoDevelop) the exact same code compiles and executes fine. Bringing the targeted iOS version up to 5.0 fixes the issue, and 6.0 also works.

Our code takes the form:

byte[] certificate = <certificate decoding>;
string certificatePassword = <certificate password decoding>;														
cert = new X509Certificate2(certificate, certificatePassword, X509KeyStorageFlags.PersistKeySet);

Where the failure is on the third line.

Version Information follows:

=== Xamarin Studio ===

Version 4.0 (build 2003)
Installation UUID: <identifying information removed>
Runtime:
	Mono 2.10.11 (mono-2-10/2baeee2)
	GTK 2.24.14
	GTK# (2.12.0.0)
	Package version: 210110000

=== Apple Developer Tools ===

Xcode 4.5 (1839)
Build 4G182

=== Xamarin.Mac ===

Xamarin.Mac: Not Installed

=== Xamarin.iOS ===

Version: 6.2.0.65 (Business Edition)

=== Xamarin.Android ===

Not Installed

=== Build Information ===

Git revision: Release ID: 400002003
<identifying information removed>
Build date: 2013-02-20 00:32:59+0000
Xamarin addins: b7a7aff09b352c13ded8a27439fd6d2250361511

=== Operating System ===

Mac OS X 10.7.5
<identifying information removed>
Comment 1 Sebastien Pouliot 2013-02-25 11:50:47 UTC
> Where the failure is on the third line.

Could you provide what's the "failure" you see ? e.g. an exception, crash ?

X509Certificate2 is a fully managed type. As such it should be independent of the iOS version it's being executed from. Also there's no recent change in the type - so it _might_ be something it depends that "acquired" a dependency on iOS 5.0 (and later).
Comment 3 Sebastien Pouliot 2013-02-25 17:51:59 UTC
The exception comes from the data, line #113 only throw if:

				if (decoder [0].Tag != 0x30)
					throw new CryptographicException (encoding_error);

and that's fully managed and won't change with iOS versions. Something must have occured earlier and affected the data itself.

Can you tell me which earlier version of MonoTouch worked (it's unrelated to the version of MonoDevelop) ? The differences between 6.2 and 6.0.10 are very minor, beside the rebranding, due to the iOS 6.0.1 release and the test/freeze around Xamarin 2.0.

Also if you can create a small test case it might prove useful since the bug might be hard to locate (it's not where it fails) and was not caught by our test suite.
Comment 4 Chris Hatton 2013-02-28 11:05:57 UTC
I performed an isolation test. Correct input data results in a valid certificate on all versions including 4.3. There must be some error further up the chain which is version dependent. Therefore this particular bug report is invalid and can be closed. Thanks Xmarain team for your considered input...