knolleary / pubsubclient

A client library for the Arduino Ethernet Shield that provides support for MQTT.
http://pubsubclient.knolleary.net/
MIT License
3.82k stars 1.47k forks source link

ESP32 One-way Authentication SSL #919

Open burakdereli opened 2 years ago

burakdereli commented 2 years ago

Hi, What do I need to do to connect to MQTT broker, which is one-way SSL. Can SSL connection be established without certificate on ESP32 side?

knolleary commented 2 years ago

That's a question for whatever network client you are using with this library. It isn't something this library deals with.

fsommer1968 commented 2 years ago

Hi,

Arduino on 8266 (quite similar to ESP32): with BearSSL to IBM Bluemix (TLS 1.2) yes! You must instantiate your MQTT similar like this:

ifdef USETLS

WiFiClientSecure wlanclient;

define MQTTPORT 8883

define HASTLS "TLS"

endif

PubSubClient mqttclient(wlanclient); later:

ifdef HASTLS

   //wlanclient.setFingerprint(watson_fingerprint);       
   wlanclient.setInsecure(); //no certificate check

endif

  wlanclient.setTimeout(8000); //my setting
  mqttclient.setServer(cfg.mqhname,MQTTPORT);

remaining initialization as usual Again: this works for 8266 Arduino