arduino-libraries / ArduinoMqttClient

ArduinoMqttClient Library for Arduino
GNU Lesser General Public License v2.1
187 stars 73 forks source link

Provide example of mutual TLS implementation #56

Open jjauzion opened 3 years ago

jjauzion commented 3 years ago

Hi, the broker I use (EMQx) is using mutual TLS, so I have to provide client certificates.

I didn't find a way in doing so so far with this lib.

I saw in the doc how to use SSL/TLS (extract below) but no indication on how I could pass certificate to the connection client.

// To connect with SSL/TLS:
// 1) Change WiFiClient to WiFiSSLClient.
// 2) Change port value from 1883 to 8883.
// 3) Change broker value to a server with a known SSL/TLS root certificate 
//    flashed in the WiFi module.

I tried using the SSLClient lib but with no success so far

Is mutual TLS possible ?

Perceval62 commented 2 years ago

@jjauzion Hi, I'm using this on a project I work on, and yes it works, if you pass in the WiFiSSLClient obj when it is time to instantiate your MqttClient obj. Note: I'm using this setup but on a SAMD controller over Ethernet with my own certificates. You may want to see if you pass in your WiFiSSLClient obj at the right time or if it is properly initialised when you pass it in, good luck !

SamShekhovtsov commented 1 year ago

@Perceval62 hi. could you please provide some details or code samples how you accomplish this? I'm trying to connect to the mosquitto MQTT TLS broker (over SSL) using Arduino MKR WiFi 1010 microcontroller and I can't find a solution so far.

Perceval62 commented 1 year ago

That snippet was quite some time ago and on a corporate repo that I no longer have access to :| Can you send a snippet of your own code ?