Make MQTT SSL connection with CA signed server certificate

0

I need to sign up for an MQTT address, but I get an exception. As far as I know, I do not need to upload any certificates, just use the server's. What should I do?

Code:

public void connect() throws MqttException{
    MqttConnectOptions options = new MqttConnectOptions();
    options.setUserName("username");
    options.setPassword("123456".toCharArray());
    options.setAutomaticReconnect(true);

    client = new MqttClient("ssl://myadress:1883", MqttClient.generateClientId());
    client.setCallback(callback);
    System.out.println(topic);
    try {
        client.connect(options);
        client.subscribe(topic);
    } catch (Exception e){
        e.printStackTrace();
    }
}

Exception:

MqttException (0) - javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

I'm using the Eclipse Paho library, and I did not find (or, if I did, I did not understand) anything too enlightening at library documentation.

    
asked by anonymous 28.11.2018 / 14:57

0 answers