Skip to content

Commit 6182690

Browse files
author
Federico Fissore
committed
Added [no]checkSSL method that sets an "insecure" boolean flag.
If insecure, "-k" parameter is added to curl and SSL certificates are not checked
1 parent cdf70e5 commit 6182690

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

libraries/Bridge/src/HttpClient.cpp

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,43 @@
1818

1919
#include "HttpClient.h"
2020

21+
HttpClient::HttpClient() :
22+
insecure(false) {
23+
// Empty
24+
}
25+
2126
unsigned int HttpClient::get(String &url) {
2227
begin("curl");
23-
addParameter("-k");
28+
if (insecure) {
29+
addParameter("-k");
30+
}
2431
addParameter(url);
2532
return run();
2633
}
2734

2835
unsigned int HttpClient::get(const char *url) {
2936
begin("curl");
30-
addParameter("-k");
37+
if (insecure) {
38+
addParameter("-k");
39+
}
3140
addParameter(url);
3241
return run();
3342
}
3443

3544
void HttpClient::getAsynchronously(String &url) {
3645
begin("curl");
37-
addParameter("-k");
46+
if (insecure) {
47+
addParameter("-k");
48+
}
3849
addParameter(url);
3950
runAsynchronously();
4051
}
4152

4253
void HttpClient::getAsynchronously(const char *url) {
4354
begin("curl");
44-
addParameter("-k");
55+
if (insecure) {
56+
addParameter("-k");
57+
}
4558
addParameter(url);
4659
runAsynchronously();
4760
}
@@ -54,4 +67,11 @@ unsigned int HttpClient::getResult() {
5467
return exitValue();
5568
}
5669

70+
void HttpClient::noCheckSSL() {
71+
insecure = true;
72+
}
73+
74+
void HttpClient::checkSSL() {
75+
insecure = false;
76+
}
5777

libraries/Bridge/src/HttpClient.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,19 @@
2323

2424
class HttpClient : public Process {
2525
public:
26+
HttpClient();
2627

2728
unsigned int get(String &url);
2829
unsigned int get(const char * url);
2930
void getAsynchronously(String &url);
3031
void getAsynchronously(const char * url);
3132
boolean ready();
3233
unsigned int getResult();
34+
void noCheckSSL();
35+
void checkSSL();
36+
37+
private:
38+
boolean insecure;
3339

3440
};
3541

0 commit comments

Comments
 (0)