Skip to content

Commit 3f92c78

Browse files
authored
Merge pull request #64 from cail/master
Option to allow insecure connection
2 parents e638dcc + 59b5538 commit 3f92c78

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/InfluxDbClient.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ InfluxDBClient::InfluxDBClient(const char *serverUrl, const char *org, const cha
171171
setConnectionParams(serverUrl, org, bucket, authToken, serverCert);
172172
}
173173

174+
void InfluxDBClient::setInsecure(bool value){
175+
_insecure = value;
176+
}
177+
174178
void InfluxDBClient::setConnectionParams(const char *serverUrl, const char *org, const char *bucket, const char *authToken, const char *certInfo) {
175179
clean();
176180
_serverUrl = serverUrl;
@@ -217,7 +221,9 @@ bool InfluxDBClient::init() {
217221
} else {
218222
wifiClientSec->setFingerprint(_certInfo);
219223
}
220-
}
224+
}
225+
if (_insecure)
226+
wifiClientSec->setInsecure();
221227
#elif defined(ESP32)
222228
WiFiClientSecure *wifiClientSec = new WiFiClientSecure;
223229
if(_certInfo && strlen_P(_certInfo) > 0) {

src/InfluxDbClient.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ class InfluxDBClient {
136136
InfluxDBClient(const char *serverUrl, const char *org, const char *bucket, const char *authToken, const char *certInfo);
137137
// Clears instance.
138138
~InfluxDBClient();
139+
// Allows insecure connection
140+
// Works only on ESP8266. No-op for ESP32
141+
void setInsecure(bool value);
139142
// precision - timestamp precision of written data
140143
// batchSize - number of points that will be written to the databases at once. Default 1 - writes immediately
141144
// bufferSize - maximum size of Points buffer. Buffer contains new data that will be written to the database
@@ -250,6 +253,8 @@ class InfluxDBClient {
250253
#ifdef ESP8266
251254
BearSSL::X509List *_cert = nullptr;
252255
#endif
256+
// if true - allow insecure connection
257+
bool _insecure = 0;
253258
// Store retry timeout suggested by server after last request
254259
int _lastRetryAfter = 0;
255260
// Sends POST request with data in body

0 commit comments

Comments
 (0)