-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Add a function for insecure HTTPS connections with HTTPClient #5277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You could also use the new begin() methods that pass in a WiFiClient(Secure). See BasicHttpsClient.ino for an example and use a WiFiClient or a BearSSL::WiFiClientSecure and use client -> setInsecure() instead of client -> setFingerprint(). Next call a URL that begins with http:// instead of http:// |
Previous comment is correct. Create a standalone WiFiClient or WiFiClientServer, configure it, then pass it as argument to begin(). |
Hey, I found this thread when facing the same issue. When using HTTPClient https;
BearSSL::WiFiClientSecure newSecure;
newSecure.setInsecure();
int checkBegin = https.begin(newSecure, "raw.githubusercontent.com", 443, "/coder137/TM4C123G/master/.gitattributes", false);
Serial.println(checkBegin);
int code = https.GET();
String payload = https.getString();
Serial.println(code);
Serial.println(payload);
// !
https.end();
newSecure.stop(); However when using the default axTLS::WifiSecure HTTPClient https;
WiFiClientSecure newSecure;
int checkBegin = https.begin(newSecure, "raw.githubusercontent.com", 443, "/coder137/TM4C123G/master/.gitattributes", false);
Serial.println(checkBegin);
int code = https.GET();
String payload = https.getString();
Serial.println(code);
Serial.println(payload);
// !
https.end();
newSecure.stop(); However in the docs it has been written that BearSSL is preferred over axTLS since the latter is deprecated. |
Basic Infos
Platform
Settings in IDE
Problem Description
BearSSL allows for 'insecure' TLS connections by calling
WiFiClientSecure::setInsecure()
function. It turns off certificate and/or fingerprint checking which is useful in some cases.Currently HTTPClient doesn't allows such connections because it lacks methods to set 'insecure' connection. While there was some argumentation against insecure connections through (#3157 for example) issues they were based on axTLS lib and also I think this aren't practical not to include this for the following reason.
Sometimes you want to have a connection initiated with some sort of public HTTPS server which you don't have control over. And which can change it's TLS cert any time or even on regular basis. It's not feasible to include every trusted CA root certificate like programs on bigger devices do to handle this. But sometimes you don't care about possible MITM attack. All you need is just to grab some data over HTTPS from 3rd party source if it's not available over plain HTTP.
It's very simply to add additional overloaded function
HTTPClient::begin()
, where 2nd argument could be of bool value for example and take false to initiate insecure connection.I've did a workaround for me as a class extension. It works but I'm not familiar with C++ well enough, a link are just for a reference here.
Probably a more convenient feature would be to parse protocol on HTTPClient::begin() when only 1 argument are supplied and initiate a insecure HTTPS connection if the url begins with
https://
.MCVE Sketch
The text was updated successfully, but these errors were encountered: