Bug 23589 - Accessing a URL with a self-signed certificate displays a System.ArgumentOutOfRangeException but allows communication
Summary: Accessing a URL with a self-signed certificate displays a System.ArgumentOutO...
Status: CONFIRMED
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 4.18.0
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: ---
Assignee: Martin Baulig
URL:
Depends on:
Blocks:
 
Reported: 2014-10-03 13:13 UTC by Benjamin Broll
Modified: 2017-04-04 13:49 UTC (History)
3 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 for Bug 23589 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Benjamin Broll 2014-10-03 13:13:37 UTC
With the latest beta version of Xamarin.Android (as of Oct 3 2014; I don't know where to find the exact version of Xamarin.Android), the following stack trace appears when connecting to an HTTPS-based URL which uses a self-signed certificate. The verification of the certificate does not fail (as it should), instead communication to the server is allowed.

ERROR building certificate chain: System.ArgumentOutOfRangeException: Argument is out of range.
  at System.DateTime.op_Subtraction (DateTime d, TimeSpan t) [0x00000] in <filename unknown>:0 
  at Android.Runtime.AndroidCurrentSystemTimeZone.IsAmbiguousTime (DateTime time) [0x0001d] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.18-series/04399d62/source/monodroid/src/Mono.Android/src/Runtime/AndroidCurrentSystemTimeZone.cs:113 
  at Android.Runtime.AndroidCurrentSystemTimeZone.GetUtcOffset (DateTime time) [0x00049] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.18-series/04399d62/source/monodroid/src/Mono.Android/src/Runtime/AndroidCurrentSystemTimeZone.cs:100 
  at System.TimeZone.ToLocalTime (DateTime time) [0x00000] in <filename unknown>:0 
  at System.DateTime.ToLocalTime () [0x00000] in <filename unknown>:0 
  at System.Security.Cryptography.X509Certificates.X509Certificate2.get_NotAfter () [0x00000] in <filename unknown>:0 
  at System.Security.Cryptography.X509Certificates.X509Certificate2Collection.Find (X509FindType findType, System.Object findValue, Boolean validOnly) [0x00000] in <filename unknown>:0 
  at System.Security.Cryptography.X509Certificates.X509Chain.SelectBestFromCollection (System.Security.Cryptography.X509Certificates.X509Certificate2 child, System.Security.Cryptography.X509Certificates.X509Certificate2Collection c) [0x00000] in <filename unknown>:0 
  at System.Security.Cryptography.X509Certificates.X509Chain.FindParent (System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) [0x00000] in <filename unknown>:0 
  at System.Security.Cryptography.X509Certificates.X509Chain.BuildChainFrom (System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) [0x00000] in <filename unknown>:0 
  at System.Security.Cryptography.X509Certificates.X509Chain.Build (System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) [0x00000] in <filename unknown>:0 
  at System.Net.ServicePointManager+ChainValidationHelper.ValidateChain (Mono.Security.X509.X509CertificateCollection certs) [0x00000] in <filename unknown>:0 
Please, report this problem to the Mono team
Comment 1 Arpit Jha 2014-10-06 11:12:39 UTC
I have checked this issue and unable to reproduce it.

I tried following steps to reproduce it.
1.Create a Xamarin Android application.
2.Did some code on button click to redirect on HTTPS  based url.
button.Click += (sender, e) => {
                
				var uri = Android.Net.Uri.Parse ("https://www.google.co.in/");
                var intent = new Intent (Intent.ActionView, uri);  
                StartActivity (intent);
            };
3.Run the application.

I observed that i am able to redirect to a HTTPS based url successfully.

Let me know if i missed anything to reproduce it.

Screencast regarding same:
http://www.screencast.com/t/65tXfqKtQG3

Application output
https://gist.github.com/sunil360/e6b5e152e8fadff2b00f
Build Output
 https://gist.github.com/sunil360/813136e8b81fd853e068

 Android device log
https://gist.github.com/sunil360/a737639d0fa29b8fbbb3
Environment Info:=== Xamarin Studio ===

Version 5.5 (build 227)
Installation UUID: 561c7a69-0a91-4bae-ad7c-f0c79d594337
Runtime:
	Mono 3.10.0 ((detached/633e444)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 310000020

=== Xamarin.Android ===

Version: 4.18.0 (Indie Edition)
Android SDK: /Users/tajinder/Desktop/android-sdk-macosx
	Supported Android versions:
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		3.2    (API level 13)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		4.5    (API level 21)
Java SDK: /usr
java version "1.7.0_67"
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

=== Apple Developer Tools ===

Xcode 5.1.1 (5085)
Build 5B1008

=== Xamarin.iOS ===

Version: 8.2.0.193 (Indie Edition)
Hash: 959c1e4
Branch: 
Build date: 2014-10-03 00:25:37-0400

=== Xamarin.Mac ===

Version: 1.10.0.18 (Indie Edition)

=== Build Information ===

Release ID: 505000227
Git revision: 7b721eeec7a2fa4c4f4de0ecd2aed4dc25edac95
Build date: 2014-10-02 15:53:38-04
Xamarin addins: 99ed56b428b31eba1efaace4d82188d6f334e6ca

=== Operating System ===

Mac OS X 10.8.4
Darwin Tajinders-iMac.local 12.4.2 Darwin Kernel Version 12.4.2
    Mon Jun 17 18:00:12 PDT 2013
    root:xnu-2050.45.8~1/RELEASE_X86_64 x86_64
Comment 2 Benjamin Broll 2014-10-06 14:32:22 UTC
In our case, we're working with System.Net.HttpWebRequest and it still occurs with the test domain that we're using. I have attached a small test project which exhibits the problematic behavior on my machine.
Comment 4 Arpit Jha 2014-10-07 02:03:56 UTC
I have checked this issue and able to reproduce it with the help of Comment 3.

I observed that getting "ERROR building certificate chain: System.ArgumentOutOfRangeException:" on button click for response.

Screencast regarding Same :
http://screencast.com/t/S2hZUMZe

Application output :
https://gist.github.com/Mohit-Kheterpal/01921b1b72c26b97c328
Build Output :
https://gist.github.com/Mohit-Kheterpal/20aa05ce2990eeded676