davidepianca98 / KMQTT

Kotlin Multiplatform MQTT client & embeddable and standalone broker
MIT License
194 stars 30 forks source link

Support for insecure connections #53

Closed yschimke closed 5 months ago

yschimke commented 5 months ago

Trying to connect to a bambu labs printer, without obvious access to certs.

Standard practice seems to be to disable TLS validation.

https://github.com/markhaehnel/bambulab/blob/main/src/client.rs#L87

    async fn connect(&self) -> Result<(), Box<dyn std::error::Error>> {
        let ssl_opts = paho_mqtt::SslOptionsBuilder::new()
            .disable_default_trust_store(true)
            .enable_server_cert_auth(false)
            .verify(false)
            .finalize();

Is this supported?

davidepianca98 commented 5 months ago

Hello, no it is not supported in the current version, but I just added it now here https://github.com/davidepianca98/KMQTT/commit/cc944898d8cc6d1e1c4a6a04b8dc1105badeb27e

It works like this:

val client = MQTTClient(
        MQTTVersion.MQTT5,
        "test.mosquitto.org",
        8883,
        TLSClientSettings(checkServerCertificate = false),
        30,
) {
    println(it.payload?.toByteArray()?.decodeToString())
}