ClientWebSocket Xamarin CERTIFICATE_VERIFY_FAILED

Steven 96 Reputation points
2021-10-29T10:49:29.03+00:00

Hello, I developing an application on Xamarin for Android and iOS for a little while and I had so far had no problems with the web socket

I use this method to connect to my server "await client.ConnectAsync(new Uri("wss://MY_URL"), cts.Token);"

Recently and surely because of recent events with Let’s Encrypt android phones can no longer connect to my server, here is the error:

Verif SN error =>System.Net.WebSockets.WebSocketException (0x80004005): Unable to connect to the remote server ---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. ---> Mono.Btls.MonoBtlsException: Ssl error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED

I tried a lot of things but I couldn’t get a result, my server certificates are in ISRG Root X1

Do you have any idea what the problem is?

thank you in advance, have a good day

Developer technologies .NET Xamarin
{count} votes

Accepted answer
  1. Steven 96 Reputation points
    2021-11-04T12:58:30.98+00:00

    Indeed there are two solutions

    1: Changing the way you use http requests on Xamarin

    So passed from ClientWebSocket to httpClient or other , or the possibility to cancel the certificate check is available even if on production it is not a solution.

    2: Update Certbot

    Update Certbot and ask again for a certificate let’s encrypt without cross-signature "DST Root CA X3"
    This worked for us

    I hope it helps some

    Good luck to you and thank you


1 additional answer

Sort by: Most helpful
  1. Ángel Rubén Valdeolmos Carmona 611 Reputation points
    2021-11-03T15:53:15.13+00:00

    I have the same problem in Android versions 7 and higher. The solution was the implementation:
    https://github.com/xamarin/xamarin-android/issues/6351#issuecomment-932944425

    I don't like it though, as I use Refit and it "complicates" token allocation.

    Did you find a server-side solution? I think xamarin should update the android sdk. In flutter this does not happen.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.