diff --git a/CHANGELOG.md b/CHANGELOG.md index a6cb6ee..32e6999 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog ## 3.7.1 [in progress] +### Features + - [#143](https://github.com/tobiasschuerg/InfluxDB-Client-for-Arduino/pull/143) - `InfluxDBClient::setInsecure` now works also for ESP32. Requires Arduino ESP32 SDK 1.0.5 or higher + ### Documentation - [#134](https://github.com/tobiasschuerg/InfluxDB-Client-for-Arduino/pull/134): - Added untrusted connection (skipping certificate validation) info to Readme diff --git a/README.md b/README.md index fb6f618..0c03a9a 100644 --- a/README.md +++ b/README.md @@ -403,7 +403,7 @@ InfluxDBClient client(INFLUXDB_URL, INFLUXDB_ORG, INFLUXDB_BUCKET, INFLUXDB_TOKE void setup() { // Set insecure connection to skip server certificate validation - client.setInsecure(true); + client.setInsecure(); } ``` diff --git a/examples/SecureBatchWrite/SecureBatchWrite.ino b/examples/SecureBatchWrite/SecureBatchWrite.ino index 42d1b8f..d47fedc 100644 --- a/examples/SecureBatchWrite/SecureBatchWrite.ino +++ b/examples/SecureBatchWrite/SecureBatchWrite.ino @@ -82,7 +82,7 @@ void setup() { sensorStatus.addTag("SSID", WiFi.SSID()); // Alternatively, set insecure connection to skip server certificate validation - //client.setInsecure(true); + //client.setInsecure(); // Accurate time is necessary for certificate validation and writing in batches // Syncing progress and the time will be printed to Serial. diff --git a/examples/SecureWrite/SecureWrite.ino b/examples/SecureWrite/SecureWrite.ino index cb18618..4b49fea 100644 --- a/examples/SecureWrite/SecureWrite.ino +++ b/examples/SecureWrite/SecureWrite.ino @@ -72,7 +72,7 @@ void setup() { sensor.addTag("SSID", WiFi.SSID()); // Alternatively, set insecure connection to skip server certificate validation - //client.setInsecure(true); + //client.setInsecure(); // Accurate time is necessary for certificate validation and writing in batches // For the fastest time sync find NTP servers in your area: https://www.pool.ntp.org/zone/ diff --git a/src/InfluxDbClient.cpp b/src/InfluxDbClient.cpp index 99b2ca0..f974f5f 100644 --- a/src/InfluxDbClient.cpp +++ b/src/InfluxDbClient.cpp @@ -141,13 +141,17 @@ bool InfluxDBClient::init() { wifiClientSec->setFingerprint(_certInfo); } } - checkMFLN(wifiClientSec, _serverUrl); #elif defined(ESP32) WiFiClientSecure *wifiClientSec = new WiFiClientSecure; - if(!_insecure && _certInfo && strlen_P(_certInfo) > 0) { - wifiClientSec->setCACert(_certInfo); - } + if (_insecure) { +#ifndef ARDUINO_ESP32_RELEASE_1_0_4 + // This works only in ESP32 SDK 1.0.5 and higher + wifiClientSec->setInsecure(); +#endif + } else if(_certInfo && strlen_P(_certInfo) > 0) { + wifiClientSec->setCACert(_certInfo); + } #endif _wifiClient = wifiClientSec; } else { diff --git a/src/InfluxDbClient.h b/src/InfluxDbClient.h index b437aea..0a15315 100644 --- a/src/InfluxDbClient.h +++ b/src/InfluxDbClient.h @@ -83,7 +83,7 @@ class InfluxDBClient { ~InfluxDBClient(); // Allows insecure connection by skiping server certificate validation. // setInsecure must be called before calling any method initiating a connection to server. - void setInsecure(bool value); + void setInsecure(bool value = true); // precision - timestamp precision of written data // batchSize - number of points that will be written to the databases at once. Default 1 - writes immediately // bufferSize - maximum size of Points buffer. Buffer contains new data that will be written to the database