0

I have several .NET MAUI 9 and Xamarin.Forms apps in production, all connecting to an Azure Web App with two instances and a direct HTTP endpoint that handles hundreds of requests per minute.

Lately on the Android apps I get

System.Net.Http.HttpRequestException: Connection failure
 ---> Javax.Net.Ssl.SSLHandshakeException: Chain validation failed
 ---> Java.Security.Cert.CertificateException: Chain validation failed
 ---> Java.Security.Cert.CertPathValidatorException: Unable to determine revocation status due to network error
 ---> Java.IO.IOException: Parse Generalized time, unsupported precision for seconds value

I use

_client = new HttpClient
{
    MaxResponseContentBufferSize = 10 * 1024 * 1024
};

and

await _client.SendAsync(request);

The new certificate starts from Fri, 31 Oct 2025 and it is valid.

4
  • This post might be helpful in your situation Commented Nov 12 at 12:38
  • How are you using the ssl certificate on your http client? Commented Nov 12 at 14:56
  • I'm not, my endpoint is "myserver.azurewebsites.net" Commented Nov 12 at 15:18
  • But I want to use https Commented Nov 12 at 15:48

2 Answers 2

0

This is from long time ago. But I remember in Xamarin I used to have problems with HttpClient when trying to access HTTPS endpoint.

I solved those problems by using HttpClient with HttpMessageHandler on Android:

    public interface INativeHttpMessageHandlerProvider
    {
        HttpMessageHandler Get();
    }


    public static class HttpClientProvider
    {
        public static HttpClient Get()
        {
            if (Device.RuntimePlatform == Device.Android)
            {
                var nativeHttpMessageHandler = DependencyService.Get<INativeHttpMessageHandlerProvider>().Get();
                return new HttpClient(nativeHttpMessageHandler);    // nativeHttpMessageHander is injected from Android project
            }
            else
            {
                return new HttpClient();
            }
        }
    }

On your Android project

 public class AndroidHttpMessageHandlerProvider : INativeHttpMessageHandlerProvider
 {
     public HttpMessageHandler Get()
     {
         return new AndroidClientHandler();
     }
 }

Then I was just using HttpClient like this:

HttpClient client = HttpClientProvider.Get();

  • Again, this is old Xamarin days, so I don't remember in which Android version this used to happen, nevertheless, I hope it helps. I don't remember finding this issue on Maui.
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, I wasn't aware of this. Going to keep an eye on it.
0

The problem is related to the default HttpClientHandler. Using SocketsHttpHandler I solved the problem.

Working HttClient instance:

_client = new HttpClient(new SocketsHttpHandler())

1 Comment

Can you edit your answer to show how? That would be useful to future readers with a similar problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.