0

I'm developing a Xamarin Forms app with an ASP.NET Core WebAPI which use the Microsoft.Datasync.Client & Microsoft.AspNetCore.Datasync libraries to do offline syncronisation.

Unfortunately, I'm getting an error when the ToListAsync() method is called on the remote table. The error tells me:

"The SSL connection could not be established, see inner exception."

My code is below:

        private async Task InitializeOfflineStore()
        {

            try
            {
                string serviceUri = "https://10.0.2.2";
                var tableName = "TodoItem";

                var options = new DatasyncClientOptions
                {
                    IdGenerator = (table) => Guid.NewGuid().ToString("N"),
                    InstallationId = null,
                    OfflineStore = null,
                    ParallelOperations = 1,
                    SerializerSettings = null,
                    TableEndpointResolver = (table) => $"/tables/{tableName.ToLowerInvariant()}",
                    UserAgent = $"Datasync/5.0 (/* Device information */)"
                };

                var client = new DatasyncClient(serviceUri, options);

                IRemoteTable<TodoItem> remoteTable = client.GetRemoteTable<TodoItem>();

                List<TodoItem> items = await remoteTable.ToListAsync(); // ERROR HAPPENS HERE

                foreach (var item in items)
                {
                    // Process each item
                    Console.WriteLine("###############" + item.Title);
                }

            }
            catch (Exception ex)
            {
                Console.WriteLine("################### Error: " + ex.Message);
            }

        }

Running the service call from the browser/Postman doesn't come up with any cert/SSL errors. I've also tried running the WebAPI on a dev server where I know there's a valid SSL cert.

Any ideas where I'm going wrong?

Inner exception below: {System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception. ---> 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 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 --- End of inner exception stack trace --- at Mono.Net.Security.MobileAuthenticatedStream.ProcessAuthentication (System.Boolean runSynchronously, Mono.Net.Security.MonoSslAuthenticationOptions options, System.Threading.CancellationToken cancellationToken) [0x0025c] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/Mono.Net.Security/MobileAuthenticatedStream.cs:310 at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore (System.IO.Stream stream, System.Net.Security.SslClientAuthenticationOptions sslOptions, System.Threading.CancellationToken cancellationToken) [0x0007b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectHelper.cs:165 --- End of inner exception stack trace --- at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore (System.IO.Stream stream, System.Net.Security.SslClientAuthenticationOptions sslOptions, System.Threading.CancellationToken cancellationToken) [0x000f6] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectHelper.cs:176 at System.Threading.Tasks.ValueTask1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813 at System.Net.Http.HttpConnectionPool.CreateConnectionAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x002d8] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs:408 at System.Threading.Tasks.ValueTask1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813 at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync (System.Threading.Tasks.ValueTask1[TResult] creationTask) [0x000a2] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs:543 at System.Threading.Tasks.ValueTask1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813 at System.Net.Http.HttpConnectionPool.SendWithRetryAsync (System.Net.Http.HttpRequestMessage request, System.Boolean doRequestAuth, System.Threading.CancellationToken cancellationToken) [0x0003f] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs:284 at System.Net.Http.RedirectHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00070] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/RedirectHandler.cs:32 at System.Net.Http.DecompressionHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00080] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/DecompressionHandler.cs:48 at System.Net.Http.HttpClient.FinishSendAsyncBuffered (System.Threading.Tasks.Task1[TResult] sendTask, System.Net.Http.HttpRequestMessage request, System.Threading.CancellationTokenSource cts, System.Boolean disposeCts) [0x0017e] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/HttpClient.cs:506 at Microsoft.Datasync.Client.Http.ServiceHttpClient.SendAsync (System.Net.Http.HttpRequestMessage requestMessage, System.Threading.CancellationToken cancellationToken) [0x00091] in <7915184494f846e5bcd4dd1e1403b2f9>:0 at Microsoft.Datasync.Client.Http.ServiceHttpClient.SendAsync (Microsoft.Datasync.Client.Http.ServiceRequest serviceRequest, System.Threading.CancellationToken cancellationToken) [0x000af] in <7915184494f846e5bcd4dd1e1403b2f9>:0 at Microsoft.Datasync.Client.Table.RemoteTable.SendRequestAsync (Microsoft.Datasync.Client.Http.ServiceRequest request, System.Threading.CancellationToken cancellationToken) [0x00095] in <7915184494f846e5bcd4dd1e1403b2f9>:0 at Microsoft.Datasync.Client.Table.RemoteTable.GetNextPageAsync (System.String query, System.String requestUri, System.Threading.CancellationToken cancellationToken) [0x000e3] in <7915184494f846e5bcd4dd1e1403b2f9>:0 at Microsoft.Datasync.Client.Table.RemoteTable1[T].GetNextPageAsync[U] (System.String query, System.String nextLink, System.Threading.CancellationToken cancellationToken) [0x00084] in <7915184494f846e5bcd4dd1e1403b2f9>:0 at Microsoft.Datasync.Client.Table.FuncAsyncPageable1+<AsPages>d__2[T].MoveNext () [0x000ae] in <7915184494f846e5bcd4dd1e1403b2f9>:0 at Microsoft.Datasync.Client.Table.FuncAsyncPageable1+d__2[T].System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult (System.Int16 token) [0x00000] in <7915184494f846e5bcd4dd1e1403b2f9>:0 at System.Threading.Tasks.ValueTask1[TResult].get_Result () [0x00028] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:818 at Microsoft.Datasync.Client.Table.AsyncPageable1+d__2[T].MoveNext () [0x0019d] in <7915184494f846e5bcd4dd1e1403b2f9>:0 at Microsoft.Datasync.Client.Table.AsyncPageable1+<GetAsyncEnumerator>d__2[T].MoveNext () [0x00240] in <7915184494f846e5bcd4dd1e1403b2f9>:0 at Microsoft.Datasync.Client.Table.AsyncPageable1+d__2[T].System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult (System.Int16 token) [0x00000] in <7915184494f846e5bcd4dd1e1403b2f9>:0 at System.Threading.Tasks.ValueTask1[TResult].get_Result () [0x00028] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:818 at Microsoft.Datasync.Client.Extensions.LinqExtensions.ToZumoListAsync[TSource] (System.Collections.Generic.IAsyncEnumerable1[T] source, System.Threading.CancellationToken cancellationToken) [0x000e0] in <7915184494f846e5bcd4dd1e1403b2f9>:0 at Microsoft.Datasync.Client.Extensions.LinqExtensions.ToZumoListAsync[TSource] (System.Collections.Generic.IAsyncEnumerable1[T] source, System.Threading.CancellationToken cancellationToken) [0x0017f] in <7915184494f846e5bcd4dd1e1403b2f9>:0 at System.Threading.Tasks.ValueTask1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813 at TodoApp.Xamarin.App.InitializeOfflineStore () [0x000fc] in C:\Users\anthony.fox\source\repos\azure-mobile-apps\samples\TodoApp\TodoApp.Xamarin\TodoApp.Xamarin\App.xaml.cs:53 }

Tony Fox
  • 1
  • 1

0 Answers0