Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable connection with encryption without certificate validation #1386

Merged
merged 2 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions main/User_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ const char* certificate PROGMEM = R"EOF("
# define MQTT_SECURE_DEFAULT false
# endif

# ifndef MQTT_CERT_VALIDATE_DEFAULT
# define MQTT_CERT_VALIDATE_DEFAULT false
# endif

# ifndef AWS_IOT
# define AWS_IOT false
# endif
Expand Down
8 changes: 7 additions & 1 deletion main/main.ino
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ static unsigned long last_ota_activity_millis = 0;
# define isDiscovered(device) device->isDisc

static bool mqtt_secure = MQTT_SECURE_DEFAULT;
static bool mqtt_cert_validate = MQTT_CERT_VALIDATE_DEFAULT;
static uint8_t mqtt_ss_index = MQTT_SECURE_SELF_SIGNED_INDEX_DEFAULT;
static String mqtt_cert = "";
static String ota_server_cert = "";
Expand Down Expand Up @@ -729,7 +730,12 @@ void setup() {
#if defined(ESP8266) || defined(ESP32)
if (mqtt_secure) {
eClient = new WiFiClientSecure;
setupTLS(MQTT_SECURE_SELF_SIGNED, mqtt_ss_index);
if (mqtt_cert_validate) {
setupTLS(MQTT_SECURE_SELF_SIGNED, mqtt_ss_index);
} else {
WiFiClientSecure* sClient = (WiFiClientSecure*)eClient;
sClient->setInsecure();
}
} else {
eClient = new WiFiClient;
}
Expand Down
1 change: 1 addition & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ build_flags =
'-DLED_SEND_RECEIVE_ON=0'
'-DMQTT_SECURE_DEFAULT=true'
'-DMQTT_SECURE_SELF_SIGNED'
'-DMQTT_CERT_VALIDATE_DEFAULT=true'
'-DMQTT_SERVER="xxxxxxxxxxxxx-ats.iot.eu-west-2.amazonaws.com"'
'-DMQTT_PORT="8883"'
'-DMQTT_USER=""'
Expand Down