mirror of
https://github.com/arduino/Arduino.git
synced 2024-12-10 21: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"
|
#include "HttpClient.h"
|
||||||
|
|
||||||
|
HttpClient::HttpClient() :
|
||||||
|
insecure(false) {
|
||||||
|
// Empty
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int HttpClient::get(String &url) {
|
unsigned int HttpClient::get(String &url) {
|
||||||
begin("curl");
|
begin("curl");
|
||||||
|
if (insecure) {
|
||||||
addParameter("-k");
|
addParameter("-k");
|
||||||
|
}
|
||||||
addParameter(url);
|
addParameter(url);
|
||||||
return run();
|
return run();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int HttpClient::get(const char *url) {
|
unsigned int HttpClient::get(const char *url) {
|
||||||
begin("curl");
|
begin("curl");
|
||||||
|
if (insecure) {
|
||||||
addParameter("-k");
|
addParameter("-k");
|
||||||
|
}
|
||||||
addParameter(url);
|
addParameter(url);
|
||||||
return run();
|
return run();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HttpClient::getAsynchronously(String &url) {
|
void HttpClient::getAsynchronously(String &url) {
|
||||||
begin("curl");
|
begin("curl");
|
||||||
|
if (insecure) {
|
||||||
addParameter("-k");
|
addParameter("-k");
|
||||||
|
}
|
||||||
addParameter(url);
|
addParameter(url);
|
||||||
runAsynchronously();
|
runAsynchronously();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HttpClient::getAsynchronously(const char *url) {
|
void HttpClient::getAsynchronously(const char *url) {
|
||||||
begin("curl");
|
begin("curl");
|
||||||
|
if (insecure) {
|
||||||
addParameter("-k");
|
addParameter("-k");
|
||||||
|
}
|
||||||
addParameter(url);
|
addParameter(url);
|
||||||
runAsynchronously();
|
runAsynchronously();
|
||||||
}
|
}
|
||||||
@ -54,4 +67,11 @@ unsigned int HttpClient::getResult() {
|
|||||||
return exitValue();
|
return exitValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HttpClient::noCheckSSL() {
|
||||||
|
insecure = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HttpClient::checkSSL() {
|
||||||
|
insecure = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
class HttpClient : public Process {
|
class HttpClient : public Process {
|
||||||
public:
|
public:
|
||||||
|
HttpClient();
|
||||||
|
|
||||||
unsigned int get(String &url);
|
unsigned int get(String &url);
|
||||||
unsigned int get(const char * url);
|
unsigned int get(const char * url);
|
||||||
@ -30,6 +31,11 @@ class HttpClient : public Process {
|
|||||||
void getAsynchronously(const char * url);
|
void getAsynchronously(const char * url);
|
||||||
boolean ready();
|
boolean ready();
|
||||||
unsigned int getResult();
|
unsigned int getResult();
|
||||||
|
void noCheckSSL();
|
||||||
|
void checkSSL();
|
||||||
|
|
||||||
|
private:
|
||||||
|
boolean insecure;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user