Skip to content

added a way to disable SSL #1416

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,13 @@ void HTTPClient::begin(String url, String httpsFingerprint) {
if(!hasPort) {
_port = 80;
}
#ifndef DISABLE_SSL
} else if(protocol.equalsIgnoreCase("https")) {
_https = true;
if(!hasPort) {
_port = 443;
}
#endif /* DISABLE_SSL */
} else {
DEBUG_HTTPCLIENT("[HTTP-Client][begin] protocol: %s unknown?!\n", protocol.c_str());
return;
Expand Down Expand Up @@ -714,6 +716,7 @@ bool HTTPClient::connect(void) {
return true;
}

#ifndef DISABLE_SSL
if(_https) {
DEBUG_HTTPCLIENT("[HTTP-Client] connect https...\n");
if(_tcps) {
Expand All @@ -724,13 +727,16 @@ bool HTTPClient::connect(void) {
_tcps = new WiFiClientSecure();
_tcp = _tcps;
} else {
#endif /* DISABLE_SSL */
DEBUG_HTTPCLIENT("[HTTP-Client] connect http...\n");
if(_tcp) {
delete _tcp;
_tcp = NULL;
}
_tcp = new WiFiClient();
#ifndef DISABLE_SSL
}
#endif /* DISABLE_SSL */

if(!_tcp->connect(_host.c_str(), _port)) {
DEBUG_HTTPCLIENT("[HTTP-Client] failed connect to %s:%u\n", _host.c_str(), _port);
Expand All @@ -739,6 +745,7 @@ bool HTTPClient::connect(void) {

DEBUG_HTTPCLIENT("[HTTP-Client] connected to %s:%u\n", _host.c_str(), _port);

#ifndef DISABLE_SSL
if(_https && _httpsFingerprint.length() > 0) {
if(_tcps->verify(_httpsFingerprint.c_str(), _host.c_str())) {
DEBUG_HTTPCLIENT("[HTTP-Client] https certificate matches\n");
Expand All @@ -748,6 +755,7 @@ bool HTTPClient::connect(void) {
return false;
}
}
#endif /* DISABLE_SSL */

// set Timeout for readBytesUntil and readStringUntil
_tcp->setTimeout(_tcpTimeout);
Expand Down
4 changes: 4 additions & 0 deletions libraries/ESP8266WiFi/src/WiFiClientSecure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ extern "C"
#define SSL_DEBUG_OPTS 0
#endif

#ifndef DISABLE_SSL

uint8_t* default_private_key = 0;
uint32_t default_private_key_len = 0;
static bool default_private_key_dynamic = false;
Expand Down Expand Up @@ -526,3 +528,5 @@ extern "C" void ax_port_free(void* ptr) {
DEBUG_TLS_MEM_PRINT("free %d, left %d\r\n", p[-3], ESP.getFreeHeap());
}
}

#endif // DISABLE_SSL