Skip to content

Commit 14808c9

Browse files
Add warning when no authenticator, drop verify() (#5205)
Print a warning when in debug mode when a BearSSL connection tries to connect without having any defined authentication methods, since it will fail. Completely remove the empty axTLS compatibilty method "::verify(char *fp, char *name)" because it can't be done w/BearSSL w/o user code changes, and always failed. Better to have a compile failure when we know at compile time the app won't do what is expected. Completes the changes started by @d-a-v in PR #4833
1 parent 18612c9 commit 14808c9

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Diff for: libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,13 @@ bool WiFiClientSecure::_connectSSL(const char* hostName) {
883883
_freeSSL();
884884
_oom_err = false;
885885

886+
#ifdef DEBUG_ESP_SSL
887+
// BearSSL will reject all connections unless an authentication option is set, warn in DEBUG builds
888+
if (!_use_insecure && !_use_fingerprint && !_use_self_signed && !_knownkey && !_certStore && !_ta) {
889+
DEBUGV("BSSL: Connection *will* fail, no authentication method is setup");
890+
}
891+
#endif
892+
886893
_sc = std::make_shared<br_ssl_client_context>();
887894
_eng = &_sc->eng; // Allocation/deallocation taken care of by the _sc shared_ptr
888895
_iobuf_in = std::shared_ptr<unsigned char>(new unsigned char[_iobuf_in_size], std::default_delete<unsigned char[]>());

Diff for: libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class WiFiClientSecure : public WiFiClient {
122122
static bool probeMaxFragmentLength(const String host, uint16_t port, uint16_t len);
123123

124124
// AXTLS compatible wrappers
125-
bool verify(const char* fingerprint, const char* domain_name) { (void) fingerprint; (void) domain_name; return false; } // Can't handle this case, need app code changes
125+
// Cannot implement this mode, we need FP before we can connect: bool verify(const char* fingerprint, const char* domain_name)
126126
bool verifyCertChain(const char* domain_name) { (void)domain_name; return connected(); } // If we're connected, the cert passed validation during handshake
127127

128128
bool setCACert(const uint8_t* pk, size_t size);

0 commit comments

Comments
 (0)