Android Question Mqtt - javax.net.ssl.SSLProtocolException

Francesco Maresca

Member
Licensed User
Longtime User
Hi,
I have a problem with mqtt library version 1.01
I have to connect via ssl connection to my mosquitto server;

I followed the tutorial at this link https://www.b4x.com/android/forum/threads/b4x-mqtt-ssl-and-self-signed-certificates.100973/#content, but I have these errors

(SSLProtocolException) javax.net.ssl.SSLProtocolException: Read error: ssl=0xb400006f97393288: Failure in SSL library, usually a protocol error
error:1000045c:SSL routines:OPENSSL_internal:TLSV1_ALERT_CERTIFICATE_REQUIRED (external/boringssl/src/ssl/tls_record.cc:594 0xb400006f9e55c848:0x00000001) and the connection does not take place.


What could be the cause of the problem?

This is my code:

B4X:
Sub Connect
    mqtt.Initialize("mqtt", "ssl://10.10.10.81:8883", "id")
    Dim mo As MqttConnectOptions
    mo.Initialize("user", "password")
    TrustAll(mo)
    mqtt.Connect2(mo)
End Sub


Sub TrustAll (mo As MqttConnectOptions)
    Dim SSLContext As JavaObject
    SSLContext = SSLContext.InitializeStatic("javax.net.ssl.SSLContext").RunMethod("getInstance", Array("TLS"))
    Dim tm As CustomTrustManager
    tm.InitializeAcceptAll
    SSLContext.RunMethod("init", Array(Null, tm, Null))
    Dim jmo As JavaObject = mo
    jmo.RunMethod("setSocketFactory", Array(SSLContext.RunMethod("getSocketFactory", Null)))
End Sub
 

Francesco Maresca

Member
Licensed User
Longtime User
The configuration I made is this:

INI:
listener 8883

cafile D:\cert\ca\ca.crt
#capath

# Path to the PEM encoded server certificate.
certfile D:\broker\broker.crt

# Path to the PEM encoded keyfile.
keyfile D:broker\broker.key
require_certificate true
password_file C:\Program Files\mosquitto\pass.txt
tls_version tlsv1.2
use_identity_as_username true
 
Upvote 0
Top