Authentication failed because the remote party has closed the transport stream.'

Good day,

We had this exception… When I do my search some site tell me it’s a TLS setup to configure…
Using the json client in our Xamarin Apps do we need a to set a special flag in the client or just tried to work with .net like:

System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

Or for backward compatibility with TLS 1.1 and prior:

System.Net.ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12; 

Incident Identifier: 0e0caf04-11ab-441d-a51a-81e21b5d1adc
CrashReporter Key: 839242DA-FB26-4942-BABE-AAE2EC1FD181
Hardware Model: iPhone8,4
Process: REIDairy.iOS [415]
Path: /var/containers/Bundle/Application/E2E94DC1-6F9A-4C36-9342-3184B7D72CEA/REIDairy.iOS.app/REIDairy.iOS
Identifier: com.lallemand.reidairy
Version: 1.0.0 (10)
Code Type: arm64
Parent Process: ??? [1]

Date/Time: undefined
Launch Time: undefined
OS Version: iPhone OS 12.2 (16E227)
Report Version: 104

Exception Type: SIGABRT
Exception Codes: #0 at 0x1d79720dc
Crashed Thread: 0

Application Specific Information:
*** Terminating app due to uncaught exception ‘SIGABRT’, reason: ‘Authentication failed because the remote party has closed the transport stream.’

Xamarin Exception Stack:
System.AggregateException: One or more errors occurred.
at System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken) <0x10149624c + 0x00118> in <2b439461a53d406abf16d6e5e34ece7f#8aaf6f1ed61a854ed8e9caedfac7d360>:0
at System.Threading.Tasks.Task.Wait () <0x10149612c + 0x0001b> in <2b439461a53d406abf16d6e5e34ece7f#8aaf6f1ed61a854ed8e9caedfac7d360>:0
at ServiceStack.PclExport.GetRequestStream (System.Net.WebRequest webRequest) <0x1041904e0 + 0x00027> in <0bdfeb25b50d4093a350760b8992ee6e#8aaf6f1ed61a854ed8e9caedfac7d360>:0
at ServiceStack.ServiceClientBase+<>c__DisplayClass178_0.b__0 (System.Net.HttpWebRequest client) <0x103fa6efc + 0x00053> in <705c892bc918492d95ed5d6320407fbb#8aaf6f1ed61a854ed8e9caedfac7d360>:0
at ServiceStack.ServiceClientBase.PrepareWebRequest (System.String httpMethod, System.String requestUri, System.Object request, System.Action1[T] sendRequestAction) <0x103f964c4 + 0x00383> in <705c892bc918492d95ed5d6320407fbb#8aaf6f1ed61a854ed8e9caedfac7d360>:0 at ServiceStack.ServiceClientBase.SendRequest (System.String httpMethod, System.String requestUri, System.Object request) <0x103f961dc + 0x000d3> in <705c892bc918492d95ed5d6320407fbb#8aaf6f1ed61a854ed8e9caedfac7d360>:0 at ServiceStack.ServiceClientBase.Send[TResponse] (System.String httpMethod, System.String relativeOrAbsoluteUrl, System.Object request) <0x103f98634 + 0x00153> in <705c892bc918492d95ed5d6320407fbb#8aaf6f1ed61a854ed8e9caedfac7d360>:0 at ServiceStack.ServiceClientBase.Post[TResponse] (ServiceStack.IReturn1[T] requestDto) <0x103f992f0 + 0x00077> in <705c892bc918492d95ed5d6320407fbb#8aaf6f1ed61a854ed8e9caedfac7d360>:0
at REIDairy.Services.UserServices.Login (System.String name, System.String password) <0x103bdb4e4 + 0x00087> in <51f02b7adf9b4439894ac2ee5e9e173c#8aaf6f1ed61a854ed8e9caedfac7d360>:0
at REIDairy.Services.SyncServices+d__0.MoveNext () <0x103afbc70 + 0x000cb> in <51f02b7adf9b4439894ac2ee5e9e173c#8aaf6f1ed61a854ed8e9caedfac7d360>:0
at REIDairy.NavigMPage+d__3.MoveNext () <0x103bb1c4c + 0x00073> in <51f02b7adf9b4439894ac2ee5e9e173c#8aaf6f1ed61a854ed8e9caedfac7d360>:0
at REIDairy.NavigMPage+d__1.MoveNext () <0x103af4240 + 0x00183> in <51f02b7adf9b4439894ac2ee5e9e173c#8aaf6f1ed61a854ed8e9caedfac7d360>:0
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__6_0 (System.Object state) <0x101506708 + 0x00050> in <2b439461a53d406abf16d6e5e34ece7f#8aaf6f1ed61a854ed8e9caedfac7d360>:0
at Foundation.NSAsyncSynchronizationContextDispatcher.Apply () <0x10321ad5c + 0x0002b> in <bbd12705940f4bb29392519af87b535b#8aaf6f1ed61a854ed8e9caedfac7d360>:0
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) <0x1030ae7b8 + 0x0009b> in <bbd12705940f4bb29392519af87b535b#8aaf6f1ed61a854ed8e9caedfac7d360>:0
at REIDairy.iOS.Application.Main (System.String[] args) <0x1010f0cd4 + 0x0001b> in <519bab59a1ca41dbad02a96d6d9d0ebf#8aaf6f1ed61a854ed8e9caedfac7d360>:0
— End of inner exception stack trace —
System.Net.WebException: Error: SecureChannelFailure (Authentication failed because the remote party has closed the transport stream.)
at System.Net.WebConnection+d__19.MoveNext () <0x101d033b0 + 0x007d0> in <74b1cf5e4c284bee8e3ac8805f0fbdaa#8aaf6f1ed61a854ed8e9caedfac7d360>:0
at System.Net.WebConnection+d__20.MoveNext () <0x101d03c30 + 0x0046f> in <74b1cf5e4c284bee8e3ac8805f0fbdaa#8aaf6f1ed61a854ed8e9caedfac7d360>:0
at System.Net.WebOperation+d__57.MoveNext () <0x101d04270 + 0x00297> in <74b1cf5e4c284bee8e3ac8805f0fbdaa#8aaf6f1ed61a854ed8e9caedfac7d360>:0
at System.Net.WebCompletionSource1+<WaitForCompletion>d__15[T].MoveNext () <0x101f13ba8 + 0x0015f> in <74b1cf5e4c284bee8e3ac8805f0fbdaa#8aaf6f1ed61a854ed8e9caedfac7d360>:0 at System.Net.HttpWebRequest+<RunWithTimeoutWorker>d__2411[T].MoveNext () <0x101cff0e0 + 0x004a0> in <74b1cf5e4c284bee8e3ac8805f0fbdaa#8aaf6f1ed61a854ed8e9caedfac7d360>:0
— End of inner exception stack trace —
System.IO.IOException: Authentication failed because the remote party has closed the transport stream.
at Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake (Mono.Net.Security.AsyncOperationStatus status) <0x101db5050 + 0x000b8> in <74b1cf5e4c284bee8e3ac8805f0fbdaa#8aaf6f1ed61a854ed8e9caedfac7d360>:0
at Mono.Net.Security.AsyncHandshakeRequest.Run (Mono.Net.Security.AsyncOperationStatus status) <0x101db2768 + 0x00013> in <74b1cf5e4c284bee8e3ac8805f0fbdaa#8aaf6f1ed61a854ed8e9caedfac7d360>:0
at Mono.Net.Security.AsyncProtocolRequest+d__24.MoveNext () <0x101f051f8 + 0x0017f> in <74b1cf5e4c284bee8e3ac8805f0fbdaa#8aaf6f1ed61a854ed8e9caedfac7d360>:0
at Mono.Net.Security.AsyncProtocolRequest+d__23.MoveNext () <0x101cfa160 + 0x00283> in <74b1cf5e4c284bee8e3ac8805f0fbdaa#8aaf6f1ed61a854ed8e9caedfac7d360>:0
at Mono.Net.Security.MobileAuthenticatedStream+d__47.MoveNext () <0x101cfa5a0 + 0x00893> in <74b1cf5e4c284bee8e3ac8805f0fbdaa#8aaf6f1ed61a854ed8e9caedfac7d360>:0
at Mono.Net.Security.MonoTlsStream+d__17.MoveNext () <0x101cfb630 + 0x00460> in <74b1cf5e4c284bee8e3ac8805f0fbdaa#8aaf6f1ed61a854ed8e9caedfac7d360>:0
at System.Net.WebConnection+d__19.MoveNext () <0x101d033b0 + 0x0069b> in <74b1cf5e4c284bee8e3ac8805f0fbdaa#8aaf6f1ed61a854ed8e9caedfac7d360>:0

What TLS you need is dependent on the HTTP Server you’re calling, e.g. since GitHub removed support for TLS v1.1 you would need to configure the .NET Web Clients to use TLS v1.2 with:

System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
1 Like