mirror of
https://github.com/arduino/Arduino.git
synced 2024-11-29 10:24:12 +01:00
Added [no]checkSSL method that sets an "insecure" boolean flag.
If insecure, "-k" parameter is added to curl and SSL certificates are not checked
This commit is contained in:
parent
cdf70e501d
commit
61826901ae
@ -18,30 +18,43 @@
|
||||
|
||||
#include "HttpClient.h"
|
||||
|
||||
HttpClient::HttpClient() :
|
||||
insecure(false) {
|
||||
// Empty
|
||||
}
|
||||
|
||||
unsigned int HttpClient::get(String &url) {
|
||||
begin("curl");
|
||||
addParameter("-k");
|
||||
if (insecure) {
|
||||
addParameter("-k");
|
||||
}
|
||||
addParameter(url);
|
||||
return run();
|
||||
}
|
||||
|
||||
unsigned int HttpClient::get(const char *url) {
|
||||
begin("curl");
|
||||
addParameter("-k");
|
||||
if (insecure) {
|
||||
addParameter("-k");
|
||||
}
|
||||
addParameter(url);
|
||||
return run();
|
||||
}
|
||||
|
||||
void HttpClient::getAsynchronously(String &url) {
|
||||
begin("curl");
|
||||
addParameter("-k");
|
||||
if (insecure) {
|
||||
addParameter("-k");
|
||||
}
|
||||
addParameter(url);
|
||||
runAsynchronously();
|
||||
}
|
||||
|
||||
void HttpClient::getAsynchronously(const char *url) {
|
||||
begin("curl");
|
||||
addParameter("-k");
|
||||
if (insecure) {
|
||||
addParameter("-k");
|
||||
}
|
||||
addParameter(url);
|
||||
runAsynchronously();
|
||||
}
|
||||
@ -54,4 +67,11 @@ unsigned int HttpClient::getResult() {
|
||||
return exitValue();
|
||||
}
|
||||
|
||||
void HttpClient::noCheckSSL() {
|
||||
insecure = true;
|
||||
}
|
||||
|
||||
void HttpClient::checkSSL() {
|
||||
insecure = false;
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
class HttpClient : public Process {
|
||||
public:
|
||||
HttpClient();
|
||||
|
||||
unsigned int get(String &url);
|
||||
unsigned int get(const char * url);
|
||||
@ -30,6 +31,11 @@ class HttpClient : public Process {
|
||||
void getAsynchronously(const char * url);
|
||||
boolean ready();
|
||||
unsigned int getResult();
|
||||
void noCheckSSL();
|
||||
void checkSSL();
|
||||
|
||||
private:
|
||||
boolean insecure;
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user