MQTTnet icon indicating copy to clipboard operation
MQTTnet copied to clipboard

Maui Hybrid Android javax.net.ssl.SSLHandshakeException

Open ImmutablLimited opened this issue 2 years ago • 4 comments

Simple vanilla implementation using Maui Hybrid fails to manage the TLS handshake when run on android device or emulator with the following error:

javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found

The same application works and connects the MQTTclient when compiled as a Maui Windows application.

Which component is your bug related to?

The MQTTnet Client

To Reproduce

Create a new MAUI Hybrid application

Use the following MqttClientOptionsBuilder...


        _mqttClient = factory.CreateMqttClient();
        
        _options = new MQTTnet.Client.MqttClientOptionsBuilder()
            .WithClientId(clientId)
            .WithTcpServer(server, port)
            .WithCredentials(username, password)
            .WithTlsOptions(new MqttClientTlsOptions()
             {
                 UseTls = true,
                 SslProtocol = SslProtocols.Tls12,
                 AllowUntrustedCertificates = true,
                 IgnoreCertificateChainErrors = true,
                 IgnoreCertificateRevocationErrors = true
             })
            .Build();

and then connect using...

var connect = await _mqttClient.ConnectAsync(_options);

Debug or release as an android application and the exception is thrown on connect.

Debug or release as a windows application and the connection succeeds

Expected behavior

Connection should honour the following...

                 AllowUntrustedCertificates = true,
                 IgnoreCertificateChainErrors = true,
                 IgnoreCertificateRevocationErrors = true

and the client should connect

ImmutablLimited avatar Sep 06 '23 20:09 ImmutablLimited

I have the same issue, the latest version(4.3.1.873) still has this problem. Can someone help us?

rokorec31 avatar Oct 17 '23 03:10 rokorec31

The code is the same for Android and Windows. So you might create a ticket at the MAUI project instead of this one.

chkr1011 avatar Oct 17 '23 15:10 chkr1011

same issue here +1

Steve0212a avatar Jan 27 '24 19:01 Steve0212a

mesmo erro

RafaelFOl avatar Mar 29 '24 23:03 RafaelFOl