Bug 27169 - HTTPS Failure : System.IO.IOException: The authentication or decryption has failed.
Summary: HTTPS Failure : System.IO.IOException: The authentication or decryption has f...
Status: CONFIRMED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: 3.12.0
Hardware: PC Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: Martin Baulig
URL:
Depends on:
Blocks:
 
Reported: 2015-02-17 23:57 UTC by Cody Beyer (MSFT)
Modified: 2017-04-04 13:14 UTC (History)
12 users (show)

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


Attachments

Description Cody Beyer (MSFT) 2015-02-17 23:57:09 UTC
### Description 

The following application attempts to connect to two web services, one behind SSL, one plain. The SSL fails, while the plain does not

### Test Case

https://www.dropbox.com/s/w9uqgwheubzvj0m/HttpsTest.zip?dl=0

### Steps to Reproduce

1. Open linked test case 
2. Run in Xamarin Studio

### Expected Results

The app should return OK status for both web sites

### Actual Results 

Only the HTTP site returns OK, the HTTPS errors with:

### Error

https://gist.github.com/CodyBeyer/c0f7e682cc51089521ac

### Version

=== Xamarin Studio ===

Version 5.7.1 (build 17)
Installation UUID: 33d88ac5-6a46-48da-ae18-b355ffac4d9e
Runtime:
	Mono 3.12.0 ((detached/de2f33f)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000076

=== Apple Developer Tools ===

Xcode 6.1.1 (6611)
Build 6A2008a

=== Xamarin.iOS ===

Version: 8.6.1.20 (Business Edition)
Hash: 3b3ef43
Branch: 
Build date: 2015-01-24 09:42:21-0500

=== Xamarin.Mac ===

Version: 1.12.0.4 (Business Edition)

=== Xamarin.Android ===

Version: 4.20.0.28 (Business Edition)
Android SDK: /Users/codybeyer/Library/Developer/Xamarin/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)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.4   (API level 19)
		5.0   (API level 21)
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)

=== Build Information ===

Release ID: 507010017
Git revision: 0bc7d3550b6b088ac25b08dcf7bbe73bcc8658b3
Build date: 2015-02-03 19:43:29-05
Xamarin addins: f7b7d34419c9ec24501bfa7c658e80a6305613e0

=== Operating System ===

Mac OS X 10.10.2
Darwin Codys-MacBook-Pro.local 14.1.0 Darwin Kernel Version 14.1.0
    Mon Dec 22 23:10:38 PST 2014
    root:xnu-2782.10.72~2/RELEASE_X86_64 x86_64
Comment 1 Prashant manu 2015-02-18 00:30:04 UTC
We have checked as per description and getting 'System.IO.IOException:'

Supplement Info:
IDE Log: https://gist.github.com/saurabh360/d974d2267d2ff7861ac7
Error details: https://gist.github.com/saurabh360/4128dc4a07580f6358cf

Environment Info:
Xamarin Studio
Version 5.7.2 (build 1)
Installation UUID: 0b7eaebc-a0ed-4b58-81df-91e378cad28c
Runtime:
	Mono 3.12.0 ((detached/de2f33f)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000076

Xamarin.Android
Version: 4.20.0.28 (Business Edition)
Android SDK: /Users/Admin_Mac/Desktop/Anddk/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)
		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)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)

Apple Developer Tools
Xcode 6.2 (6770)
Build 6C121

Xamarin.iOS
Version: 8.9.1.126 (Business Edition)
Hash: d7d470e
Branch: master
Build date: 2015-02-12 00:28:19-0500

Xamarin.Mac
Version: 1.12.0.6 (Business Edition)

Build Information
Release ID: 507020001
Git revision: 103486e2547553077836a5ba20a973487b983830
Build date: 2015-02-13 11:56:36-05
Xamarin addins: 8dd5b934e86ef0595c022dd3930fd40e3376ab4c

Operating System
Mac OS X 10.10.2
Darwin Admin-Macs-Mac-mini.local 14.1.0 Darwin Kernel Version 14.1.0
    Thu Nov 13 18:36:56 PST 2014
    root:xnu-2782.10.65~2/RELEASE_X86_64 x86_64
Comment 2 Miguel de Icaza [MSFT] 2015-02-18 11:38:44 UTC
Simpler repro:

csharp> using System.Net;
csharp> var w = new WebClient ();
csharp> w.DownloadString ("https://www.cminds.com")

This is a Mono class libraries issue.
Comment 4 Brendan Zagaeski (Xamarin Support) 2015-02-26 23:12:13 UTC
Actually comment 3 is inaccurate. Sorry about that. The `curl` command I listed only demonstrates that https://www.cminds.com/ _includes_ support for TLS 1.2. It does not indicate that the site _excludes_ support for other versions of TLS.

One better way to check which versions of TLS a server supports is to use the online testing tool at https://www.ssllabs.com/ssltest/.

All that said, I should note that the server at https://www.cminds.com/ has been modified since this bug was originally filed, so the test cases from comment 0 and comment 2 no longer fail for that particular website.
Comment 5 Robert 2015-07-21 04:44:50 UTC
I have run into the same issue when attempting to create a WCF servicehost that runs on https.
A small test project can be downloaded here:
https://www.dropbox.com/s/5noopm1zuw8q6w9/WcfHttpsTest.zip?dl=0
It includes a host and client console application, http works fine, https returns the same error as mentioned above.

I am using Ubuntu 14.04, Mono version 4.0.2, MonoDevelop version 5.9.4.

The very same code of the sample applications work fine under Win8.1 when compiled with VS2010 and C#.
This was the trigger for me to report this as an issue.


Here are the steps I took to setup the certificate:
sudo mozroots --import --machine --sync
makecert -r -eku 1.3.6.1.5.5.7.3.1 -n "CN=Cert4SSL" -sv cert.pvk cert.cer
sudo certmgr -add -c -m Trust cert.cer
httpcfg -add -port 6067 -cert cert.cer -pvk cert.pvk

Here is the complete stacktrace of the error:
Error: System.Net.WebException: Error: SendFailure (Error writing headers) ---> System.Net.WebException: Error writing headers ---> System.IO.IOException: The authentication or decryption has failed. ---> Mono.Security.Protocol.Tls.TlsException: The authentication or decryption has failed.
  at Mono.Security.Protocol.Tls.RecordProtocol.ProcessAlert (AlertLevel alertLevel, AlertDescription alertDesc) [0x0001a] in <filename unknown>:0 
  at Mono.Security.Protocol.Tls.RecordProtocol.InternalReceiveRecordCallback (IAsyncResult asyncResult) [0x000d0] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at Mono.Security.Protocol.Tls.SslClientStream.EndNegotiateHandshake (IAsyncResult result) [0x0003b] in <filename unknown>:0 
  at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (IAsyncResult asyncResult) [0x0000c] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  --- End of inner exception stack trace ---
  at System.Net.HttpWebRequest.EndGetRequestStream (IAsyncResult asyncResult) [0x00043] in <filename unknown>:0 
  at System.ServiceModel.Channels.HttpRequestChannel+<BeginProcessRequest>c__AnonStorey1.<>m__0 (IAsyncResult r) [0x0001d] in <filename unknown>:0

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