Skip to content

Commit 6c33b48

Browse files
authored
Merge pull request #143 from bonitoo-io/feat/esp32_skd_upg
feat: setInsecure also for ESP32
2 parents 5b51bdb + 34d6141 commit 6c33b48

File tree

6 files changed

+15
-8
lines changed

6 files changed

+15
-8
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22
## 3.7.1 [in progress]
3+
### Features
4+
- [#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
5+
36
### Documentation
47
- [#134](https://github.com/tobiasschuerg/InfluxDB-Client-for-Arduino/pull/134):
58
- Added untrusted connection (skipping certificate validation) info to Readme

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ InfluxDBClient client(INFLUXDB_URL, INFLUXDB_ORG, INFLUXDB_BUCKET, INFLUXDB_TOKE
403403

404404
void setup() {
405405
// Set insecure connection to skip server certificate validation
406-
client.setInsecure(true);
406+
client.setInsecure();
407407
}
408408
```
409409

examples/SecureBatchWrite/SecureBatchWrite.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ void setup() {
8282
sensorStatus.addTag("SSID", WiFi.SSID());
8383

8484
// Alternatively, set insecure connection to skip server certificate validation
85-
//client.setInsecure(true);
85+
//client.setInsecure();
8686

8787
// Accurate time is necessary for certificate validation and writing in batches
8888
// Syncing progress and the time will be printed to Serial.

examples/SecureWrite/SecureWrite.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void setup() {
7272
sensor.addTag("SSID", WiFi.SSID());
7373

7474
// Alternatively, set insecure connection to skip server certificate validation
75-
//client.setInsecure(true);
75+
//client.setInsecure();
7676

7777
// Accurate time is necessary for certificate validation and writing in batches
7878
// For the fastest time sync find NTP servers in your area: https://www.pool.ntp.org/zone/

src/InfluxDbClient.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,17 @@ bool InfluxDBClient::init() {
141141
wifiClientSec->setFingerprint(_certInfo);
142142
}
143143
}
144-
145144
checkMFLN(wifiClientSec, _serverUrl);
146145
#elif defined(ESP32)
147146
WiFiClientSecure *wifiClientSec = new WiFiClientSecure;
148-
if(!_insecure && _certInfo && strlen_P(_certInfo) > 0) {
149-
wifiClientSec->setCACert(_certInfo);
150-
}
147+
if (_insecure) {
148+
#ifndef ARDUINO_ESP32_RELEASE_1_0_4
149+
// This works only in ESP32 SDK 1.0.5 and higher
150+
wifiClientSec->setInsecure();
151+
#endif
152+
} else if(_certInfo && strlen_P(_certInfo) > 0) {
153+
wifiClientSec->setCACert(_certInfo);
154+
}
151155
#endif
152156
_wifiClient = wifiClientSec;
153157
} else {

src/InfluxDbClient.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class InfluxDBClient {
8383
~InfluxDBClient();
8484
// Allows insecure connection by skiping server certificate validation.
8585
// setInsecure must be called before calling any method initiating a connection to server.
86-
void setInsecure(bool value);
86+
void setInsecure(bool value = true);
8787
// precision - timestamp precision of written data
8888
// batchSize - number of points that will be written to the databases at once. Default 1 - writes immediately
8989
// bufferSize - maximum size of Points buffer. Buffer contains new data that will be written to the database

0 commit comments

Comments
 (0)