1

I am communicating with a server that uses mutual TLS v1.2. I have been able to make this request in a c# console application, but when I copy this exact code to Xamarin forms, my RestClient gives me an exception: "Connection reset by peer" after a few seconds.

The code:

var client = new RestClient("https://api-sandbox.rabobank.nl/openapi/sandbox/payments/account-information/ais/v3/accounts");

        ServicePointManager.Expect100Continue = true;
        ServicePointManager.DefaultConnectionLimit = 9999;
        ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

        client.ClientCertificates = new X509CertificateCollection() { certificate };
        client.Proxy = new WebProxy();

        var request = new RestRequest(Method.GET);
        var response = client.Execute(request);
        Console.WriteLine(response.StatusCode);
        Console.WriteLine(response.Content);

I am unable to share my API keys and such, for obvious reasons. These are added through headers and are removed from the code snippet.

Things I have tried:

  • I checked if the projects are set to use TLS 1.2, both iOS and Android are.

  • I tried this in simulators and on real devices

  • I tried using this library, but whenever I try to add the certificate to the clientcertificate list of the handler, I get a NotImplementedException thrown.
Luca Panjer
  • 125
  • 2
  • 11
  • The remote server has sent you a RST packet, which indicates an immediate dropping of the connection, rather than the usual handshake. This bypasses the normal half-closed state transition. Refer to this issue https://stackoverflow.com/questions/1434451/what-does-connection-reset-by-peer-mean – Lucas Zhang Sep 26 '18 at 06:38
  • @LucasZ Thank you, but I already knew that. This doesn't solve my problem though. – Luca Panjer Sep 26 '18 at 06:58

0 Answers0