ArduinoMqttClient icon indicating copy to clipboard operation
ArduinoMqttClient copied to clipboard

Provide example of mutual TLS implementation

Open jjauzion opened this issue 3 years ago • 3 comments

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 ?

jjauzion avatar Jun 18 '21 16:06 jjauzion

@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 !

Perceval62 avatar Sep 15 '21 15:09 Perceval62

@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.

SamShekhovtsov avatar Aug 27 '23 23:08 SamShekhovtsov

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 ?

Perceval62 avatar Aug 28 '23 13:08 Perceval62