Drake
Drake

Reputation: 2703

Android The SSL connection could not be established

My Xamarin.Android project was working fine until today. Now my code is not working anymore:

var client = new RestClient("https://myapp.auth0.com/oauth/ro");
var request = new RestRequest();
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;            
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "some_json", ParameterType.RequestBody);
RestResponse response = await client.ExecutePostAsync(request);
Auth0Response auth0Response = JsonConvert.DeserializeObject<MyAuth0Response>(response.Content);

The response.Content is null and the request returns an error message:

The SSL connection could not be established

Inner exception:

InnerException {System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. ---> Mono.Btls.MonoBtlsException: Ssl error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED} at /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/boringssl/ssl/handshake_client.c:1132

Inner message:

Authentication failed, see inner exception.

Stack trace:

at Mono.Btls.MonoBtlsContext.ProcessHandshake () [0x00042] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/Mono.Btls/MonoBtlsContext.cs:220 at Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake (Mono.Net.Security.AsyncOperationStatus status, System.Boolean renegotiate) [0x000da] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/Mono.Net.Security/MobileAuthenticatedStream.cs:715 at (wrapper remoting-invoke-with-check) Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake(Mono.Net.Security.AsyncOperationStatus,bool) at Mono.Net.Security.AsyncHandshakeRequest.Run (Mono.Net.Security.AsyncOperationStatus status) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/Mono.Net.Security/AsyncProtocolRequest.cs:289 at Mono.Net.Security.AsyncProtocolRequest.ProcessOperation (System.Threading.CancellationToken cancellationToken) [0x000fc] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/Mono.Net.Security/AsyncProtocolRequest.cs:223

Upvotes: 0

Views: 1161

Answers (1)

John Irvine
John Irvine

Reputation: 196

I had this exact problem, app worked fine on IOS but showed this error on Android, so mislead..

Issue was the simplest. I'd installed my nice shiny new certificate on Apache server but had stupidly made SSLCertificateChainFile the certificate domain.net.crt where it should have been the root (digicert....crt).

Just maybe this will prevent one person chasing their tail (and question the validity of iPhone and even web - as i tested on chrome) as well - ssl auth process???)

Upvotes: 0

Related Questions