Skip to content

Commit

Permalink
Added insecure SSL
Browse files Browse the repository at this point in the history
  • Loading branch information
couin3 committed Oct 5, 2020
1 parent 08f7f1c commit 4132abe
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
21 changes: 21 additions & 0 deletions RFLink/6_WiFi_MQTT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@ boolean bResub; // uplink reSubscribe after setup only

// Update these with values suitable for your network.

#ifdef MQTT_SSL
#include <WiFiClientSecure.h>
WiFiClientSecure WIFIClient;
#else //SSL
#include <WiFiClient.h>
WiFiClient WIFIClient;
#endif //SSL

PubSubClient MQTTClient; // MQTTClient(WIFIClient);

void callback(char *, byte *, unsigned int);
Expand Down Expand Up @@ -74,8 +81,22 @@ void setup_WIFI()

void setup_MQTT()
{
Serial.print(F("SSL :\t\t\t"));
#ifdef MQTT_SSL
if (MQTT_PORT == "")
MQTT_PORT = "8883"; // just in case ....
#ifdef CHECK_CACERT
Serial.println(F("Using ca_cert"));
WIFIClient.setCACert(ca_cert);
#else
Serial.println(F("Insecure (No Key/Cert/Fp)"));
#endif // MQTT_CACERT
#else
if (MQTT_PORT == "")
MQTT_PORT = "1883"; // just in case ....
Serial.println(F("Not Set"));
#endif //SSL

MQTTClient.setClient(WIFIClient);
MQTTClient.setServer(MQTT_SERVER.c_str(), MQTT_PORT.toInt());
MQTTClient.setCallback(callback);
Expand Down
2 changes: 2 additions & 0 deletions RFLink/RFLink.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#define MQTT_LOOP_MS 1000 // MQTTClient.loop(); call period (in mSec)
#define MQTT_RETAINED_0 false // Retained option
#define MQTT_LWT // Let know if Module is Online or Offline via MQTT Last Will message
#define MQTT_SSL // Send MQTT messages over SSL
// #define CHECK_CACERT // Send MQTT SSL CA Certificate
#endif

// Debug default
Expand Down

0 comments on commit 4132abe

Please sign in to comment.