Skip to content

Commit 5d5ba10

Browse files
committed
allow configuring insecure connection
1 parent 404a8cc commit 5d5ba10

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/InfluxDbClient.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ InfluxDBClient::InfluxDBClient(const char *serverUrl, const char *org, const cha
174174
setConnectionParams(serverUrl, org, bucket, authToken, serverCert);
175175
}
176176

177+
void InfluxDBClient::setInsecure(bool value){
178+
_insecure = value;
179+
}
180+
177181
void InfluxDBClient::setConnectionParams(const char *serverUrl, const char *org, const char *bucket, const char *authToken, const char *certInfo) {
178182
clean();
179183
_serverUrl = serverUrl;
@@ -221,6 +225,8 @@ bool InfluxDBClient::init() {
221225
wifiClientSec->setCACert(_certInfo);
222226
}
223227
#endif
228+
if (_insecure)
229+
wifiClientSec->setInsecure();
224230
_wifiClient = wifiClientSec;
225231
} else {
226232
_wifiClient = new WiFiClient;

src/InfluxDbClient.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ class InfluxDBClient {
134134
InfluxDBClient(const char *serverUrl, const char *org, const char *bucket, const char *authToken, const char *certInfo);
135135
// Clears instance.
136136
~InfluxDBClient();
137+
// Allows insecure connection
138+
void setInsecure(bool value);
137139
// precision - timestamp precision of written data
138140
// batchSize - number of points that will be written to the databases at once. Default 1 - writes immediately
139141
// bufferSize - maximum size of Points buffer. Buffer contains new data that will be written to the database
@@ -242,6 +244,8 @@ class InfluxDBClient {
242244
#ifdef ESP8266
243245
BearSSL::X509List *_cert = nullptr;
244246
#endif
247+
// if true - allow insecure connection
248+
int _insecure = 0;
245249
// Store retry timeout suggested by server after last request
246250
int _lastRetryAfter = 0;
247251
// Sends POST request with data in body

0 commit comments

Comments
 (0)