Bug 57106 - [Client Certificates] "System.Net.WebException: The request timed out" in iOS after Xamarin update
Summary: [Client Certificates] "System.Net.WebException: The request timed out" in iOS...
Alias: None
Product: iOS
Classification: Xamarin
Component: BCL Class Libraries (show other bugs)
Version: XI 10.10 (d15-2)
Hardware: PC Windows
: --- normal
Target Milestone: Future Cycle (TBD)
Assignee: Martin Baulig
Depends on: 58891
  Show dependency tree
Reported: 2017-06-02 13:59 UTC by Emiliano
Modified: 2017-10-10 12:18 UTC (History)
9 users (show)

See Also:
Tags: Shiproom
Is this bug a regression?: Yes
Last known good build: XI 10.6 with MonoTLS

Test Solution (14.46 KB, application/x-zip-compressed)
2017-06-02 14:06 UTC, Emiliano

Description Emiliano 2017-06-02 13:59:26 UTC
Hi all,
We have three apps that stopped working in the iOS version.
After the latest update Xamarin.iOS (10.10), when the app tries to connect the backend (HttpWebRequest with X509Certificate2 certificate), it stays freeze for a while and then I got a time out. I also have the app for Android but that one still working fine.
In our previous version, we had set Mono (managed) SSL/TSL but according to the release notes it was removed on 10.8 and it only supports AppleTLS.
I've upgraded the protocol support at our backend (Forefront TMG) so now we also have TLS 1.1 and 1.2 with forward secrecy (I've also been changing the cipher suites order) but I can't trace the request in the backend, I only get the timeout after a while waiting. We need a clue about what is not working on this communication after Mono TLS Removal.
Pls, find attached a test solution. We need some quick help because we need to deploy some changes and we can't because of it.

Thank you!

Comment 1 Emiliano 2017-06-02 14:06:46 UTC
Created attachment 22653 [details]
Test Solution
Comment 2 Manuel de la Peña 2017-06-07 10:10:13 UTC

Can you please provide the full environment information used to build the failing version? That would include the mono version and the xamarin version.

Easiest way to get exact version information:
 - On Visual Studio for Mac: "Visual Studio" menu, "About Visual Studio" item, "Show Details" button.
 - On Visual Studio for Windows: "Help menu", "About Microsoft Visual Studio" item.
 Then copy/paste the version information (you can use the "Copy Information" button).
Comment 3 Ammar Mheir 2017-06-12 16:12:20 UTC
Here is the version information, I am currently providing assistance and was able to gather some data after some troubleshooting: 

##Version Information

=== Xamarin Studio Community ===

Version 6.3 (build 864)
Installation UUID: 5188a613-2045-4b42-b1ad-0a4d4c3ddaf2
	Mono (2017-02/5077205) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 500010001

=== NuGet ===


=== Xamarin.Profiler ===

'/Applications/Xamarin Profiler.app' not found

=== Apple Developer Tools ===

Xcode 8.2.1 (11766.1)
Build 8C1002

=== Xamarin.iOS ===

Version: (Xamarin Studio Community)
Hash: d2270eec
Branch: d15-2
Build date: 2017-05-22 16:30:53-0400

=== Xamarin.Android ===

Version: (Xamarin Studio Community)
Android SDK: /Users/lagash/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		4.4 (API level 19)
		6.0 (API level 23)
		7.1 (API level 25)

SDK Tools Version: 25.2.5
SDK Platform Tools Version: 25.0.4
SDK Build Tools Version: 23.0.2

Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

Android Designer EPL code available here:

=== Xamarin.Mac ===

Version: (Xamarin Studio Community)

=== Xamarin Inspector ===

Not Installed

=== Build Information ===

Release ID: 603000864
Git revision: 6c2f6737278ccc3e81e12276d49c0d92f975f189
Build date: 2017-04-24 11:26:01-04
Xamarin addins: d8d46e577d8507c35260ce9d73df3c33415bb214
Build lane: monodevelop-lion-d15-1

=== Operating System ===

Mac OS X 10.11.6
Darwin la-MacBook-Pro-de-Lagash.local 15.6.0 Darwin Kernel Version 15.6.0
    Tue Apr 11 16:00:51 PDT 2017
    root:xnu-3248. x86_64

=== Enabled user installed addins ===

Gorilla Player

##Additional Information

Even when switching to a different HttpClient implementation such as NSUrlSession we get the same error:

>System.Net.WebException: The request timed out
>  at System.Net.HttpWebRequest.EndGetResponse (System.IAsyncResult asyncResult) [0x00059] in /Library/Frameworks/Xamarin.iOS.framework/Versions/ 
>  at System.Net.HttpWebRequest.GetResponse () [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/ 
>  at HttpsRequestsiOS.ViewController.MakeRequest () [0x00095] in /Users/lagash/Desktop/HttpsRequestsiOS/HttpsRequestsiOS 3/HttpsRequestsiOS 2/HttpsRequestsiOS/ViewController.cs:63
Comment 5 Ammar Mheir 2017-06-16 21:32:54 UTC
I have downloaded and downgraded Xamarin Studio to version 6.2.1 along with Xamarin.iOS to version 10.6.

After this, the menu option in iOS Build settings for SSL/TLS implementation has reappeared again and I set the TLS implementation to MonoTLS keeping the HttpClient implementation on Managed. 

After rebuilding, the connection completes successfully. However switching the TLS implementation back to AppleTLS results in the same error, Request Timed Out.
Comment 6 Marek Safar 2017-07-25 14:48:48 UTC
Martin, this looks like serious regression could you please investigate the underlying issue ASAP.
Comment 7 Xavier 2017-10-06 13:17:58 UTC
I'm having this issue too in Xamarin.Mac app. Any news on this?

I've been building my app against Mono 4.8.1 for a couple of months now because of this.
Comment 8 Ammar Mheir 2017-10-09 23:21:56 UTC

I just wanted to confirm with if you are also adding the client certificate via HttpWebRequest.ClientCertificate.Add(). 

We are creating our X509Certificate2 and adding it this way, and latest Mono versions will cause the web request to time out. Just wanted to see if you are seeing this same issue using the same functionality.
Comment 9 Xavier 2017-10-10 12:18:55 UTC
I might have been a bit to fast on this. I'm not sure I have the exact same problem and more of the same symptoms. I'm sorry if I'm confusing issues.

I've explained more in detail my issue on a forum post here: https://forums.xamarin.com/discussion/104118/timeout-exception-httpwebrequest-getresponse-in-mono-5-x#latest

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