Skip to content

Commit ed685e5

Browse files
committed
fix _fingerprint is set checks for ESP32
see #633 and #632
1 parent 7c3b1b7 commit ed685e5

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/WebSocketsClient.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,11 @@ void WebSocketsClient::loop(void) {
229229
#else
230230
#error setCACert not implemented
231231
#endif
232-
#if defined(SSL_BARESSL)
233-
} else if(_fingerprint) {
232+
#if defined(ESP32)
233+
} else if(!SSL_FINGERPRINT_IS_SET) {
234+
_client.ssl->setInsecure();
235+
#elif defined(SSL_BARESSL)
236+
} else if(SSL_FINGERPRINT_IS_SET) {
234237
_client.ssl->setFingerprint(_fingerprint);
235238
} else {
236239
_client.ssl->setInsecure();
@@ -865,14 +868,14 @@ void WebSocketsClient::connectedCb() {
865868

866869
#if defined(HAS_SSL)
867870
#if defined(SSL_AXTLS) || defined(ESP32)
868-
if(_client.isSSL && _fingerprint.length()) {
871+
if(_client.isSSL && SSL_FINGERPRINT_IS_SET) {
869872
if(!_client.ssl->verify(_fingerprint.c_str(), _host.c_str())) {
870873
DEBUG_WEBSOCKETS("[WS-Client] certificate mismatch\n");
871874
WebSockets::clientDisconnect(&_client, 1000);
872875
return;
873876
}
874877
#else
875-
if(_client.isSSL && _fingerprint) {
878+
if(_client.isSSL && SSL_FINGERPRINT_IS_SET) {
876879
#endif
877880
} else if(_client.isSSL && !_CA_cert) {
878881
#if defined(SSL_BARESSL)

src/WebSocketsClient.h

+2
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,14 @@ class WebSocketsClient : protected WebSockets {
112112
#ifdef SSL_AXTLS
113113
String _fingerprint;
114114
const char * _CA_cert;
115+
#define SSL_FINGERPRINT_IS_SET (_fingerprint.length())
115116
#define SSL_FINGERPRINT_NULL ""
116117
#else
117118
const uint8_t * _fingerprint;
118119
BearSSL::X509List * _CA_cert;
119120
BearSSL::X509List * _client_cert;
120121
BearSSL::PrivateKey * _client_key;
122+
#define SSL_FINGERPRINT_IS_SET (_fingerprint != NULL)
121123
#define SSL_FINGERPRINT_NULL NULL
122124
#endif
123125

0 commit comments

Comments
 (0)