Bug 16947 - SSL POST GetRequestStream gets exception 'authentication or decryption has failed'
Summary: SSL POST GetRequestStream gets exception 'authentication or decryption has fa...
Status: RESOLVED INVALID
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 4.10.1
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2013-12-23 13:14 UTC by Allie Miller
Modified: 2017-08-07 20:47 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 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 Allie Miller 2013-12-23 13:14:10 UTC
Filed on behalf of a user experiencing a similar issue to Bug #8312 which is an internal, Xamarin.iOS bug. 

This issue occurs for the user when they attempt to deploy to a Nexus 7 running Android 4.4.

Workaround:
They add the following code to the project to fix the error, however it is not secure:

ServicePointManager.ServerCertificateValidationCallback += (o, certificate,chain, errors) => true;


Versioning Information:
=== Xamarin Studio ===
Version 4.2.2 (build 2)

Installation UUID: a964fa00-8ff4-4b65-8a4b-e99fb77b25a5

Runtime:

Microsoft .NET 4.0.30319.18408

GTK+ 2.24.20 theme: MS-Windows

GTK# (2.12.0.0)
=== Xamarin.Android ===
Version: 4.10.1 (Business Edition)

Android SDK: C:\Users\USERNAMEOMITTED\AppData\Local\Android\android-sdk

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)

Java SDK: C:\Program Files (x86)\Java\jdk1.6.0_39

java version "1.6.0_39"

Java(TM) SE Runtime Environment (build 1.6.0_39-b04)

Java HotSpot(TM) Client VM (build 20.14-b01, mixed mode, sharing)

=== Build Information ===

Release ID: 402020002

c5f82958ae7d9af652b44b87ceff777b3ad19b91

Build date: 2013-11-19 10:28:29Z

Xamarin addins: a4044fee09138f6fd031a9944b7caaeb51e57e80

=== Operating System ===
Windows 6.1.7601.65536 (64-bit)
Comment 1 Jonathan Pryor 2013-12-26 10:13:09 UTC
Please provide a repro and/or the full stack trace of the error.

Related: presumably this is an HTTPS url. If you try to access the same URL from the Chrome or Browser apps on the same device, is there a request to accept the certificate? (i.e. is there a screen saying e.g. "the certificate is invalid", and asking you to view the site anyway?) If there is an "override" screen, then this is By Design.
Comment 5 Wesley Honeycutt 2013-12-31 13:18:34 UTC
I apologize for the delay, I was finally able to reproduce it again and here is the stack trace/debug information


ex.Message
Error getting response stream (Write: The authentication or decryption has failed.): SendFailure

ex.StackTrace
at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 \n  at System.Net.HttpWebRequest.GetResponse () [0x00000] in <filename unknown>:0 \n  at SPSEntityLib.WebUtils.Get (System.String url, System.Net.WebProxy proxy) [0x00040] in d:\\Dev\\SPSUIAndroid\\AndroidEntityLib\\SyncRelationship.cs:3340

ex.InnerException
{System.IO.IOException: The authentication or decryption has failed. ---> Mono.Security.Protocol.Tls.TlsException: Invalid certificate received from server. Error code: 0xffffffff800b010a
  at Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.RemoteValidation (Mono.Security.Protocol.Tls.ClientContext context, AlertDescription description) [0x00000] in <filename unknown>:0 
  at Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.validateCertificates (Mono.Security.X509.X509CertificateCollection certificates) [0x00000] in <filename unknown>:0 
  at Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.ProcessAsTls1 () [0x00000] in <filename unknown>:0 
  at Mono.Security.Protocol.Tls.Handshake.HandshakeMessage.Process () [0x00000] in <filename unknown>:0 
  at Mono.Security.Protocol.Tls.ClientRecordProtocol.ProcessHandshakeMessage (Mono.Security.Protocol.Tls.TlsStream handMsg) [0x00000] in <filename unknown>:0 
  at Mono.Security.Protocol.Tls.RecordProtocol.InternalReceiveRecordCallback (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 }
    base: {System.SystemException}
	
ex.InnerException.InnerException
{Mono.Security.Protocol.Tls.TlsException: Invalid certificate received from server. Error code: 0xffffffff800b010a
  at Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.RemoteValidation (Mono.Security.Protocol.Tls.ClientContext context, AlertDescription description) [0x00000] in <filename unknown>:0 
  at Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.validateCertificates (Mono.Security.X509.X509CertificateCollection certificates) [0x00000] in <filename unknown>:0 
  at Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.ProcessAsTls1 () [0x00000] in <filename unknown>:0 
  at Mono.Security.Protocol.Tls.Handshake.HandshakeMessage.Process () [0x00000] in <filename unknown>:0 
  at Mono.Security.Protocol.Tls.ClientRecordProtocol.ProcessHandshakeMessage (Mono.Security.Protocol.Tls.TlsStream handMsg) [0x00000] in <filename unknown>:0 
  at Mono.Security.Protocol.Tls.RecordProtocol.InternalReceiveRecordCallback (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 }
    base: {System.Exception}
    Alert: {Mono.Security.Protocol.Tls.Alert}
	
ex.InnerException.InnerException.StackTrace
	at Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.RemoteValidation (Mono.Security.Protocol.Tls.ClientContext context, AlertDescription description) [0x00000] in <filename unknown>:0 \n  at Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.validateCertificates (Mono.Security.X509.X509CertificateCollection certificates) [0x00000] in <filename unknown>:0 \n  at Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.ProcessAsTls1 () [0x00000] in <filename unknown>:0 \n  at Mono.Security.Protocol.Tls.Handshake.HandshakeMessage.Process () [0x00000] in <filename unknown>:0 \n  at Mono.Security.Protocol.Tls.ClientRecordProtocol.ProcessHandshakeMessage (Mono.Security.Protocol.Tls.TlsStream handMsg) [0x00000] in <filename unknown>:0 \n  at Mono.Security.Protocol.Tls.RecordProtocol.InternalReceiveRecordCallback (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 
	
ex.InnerException.InnerException.Alert
{Mono.Security.Protocol.Tls.Alert}
    Description: Mono.Security.Protocol.Tls.AlertDescription.CertificateUnknown
    IsCloseNotify: false
    IsWarning: true
    Level: Mono.Security.Protocol.Tls.AlertLevel.Warning
    Message: "The authentication or decryption has failed."
Comment 7 Jon Douglas [MSFT] 2017-08-07 20:47:06 UTC
Thank you for taking the time to submit this report. After reviewing the description of this bug, we believe it no longer affects the current version of Xamarin.Android. If you are still experiencing the issue after updating your packages, please reopen this report with an attached reproduction.