forked from Links2004/arduinoWebSockets
Compare commits
1 Commits
2.6.0
...
esp32-ssl-
Author | SHA1 | Date | |
---|---|---|---|
f6e730c2b4 |
@ -229,8 +229,11 @@ void WebSocketsClient::loop(void) {
|
|||||||
#else
|
#else
|
||||||
#error setCACert not implemented
|
#error setCACert not implemented
|
||||||
#endif
|
#endif
|
||||||
#if defined(SSL_BARESSL)
|
#if defined(ESP32)
|
||||||
} else if(_fingerprint) {
|
} else if(!SSL_FINGERPRINT_IS_SET) {
|
||||||
|
_client.ssl->setInsecure();
|
||||||
|
#elif defined(SSL_BARESSL)
|
||||||
|
} else if(SSL_FINGERPRINT_IS_SET) {
|
||||||
_client.ssl->setFingerprint(_fingerprint);
|
_client.ssl->setFingerprint(_fingerprint);
|
||||||
} else {
|
} else {
|
||||||
_client.ssl->setInsecure();
|
_client.ssl->setInsecure();
|
||||||
@ -865,14 +868,14 @@ void WebSocketsClient::connectedCb() {
|
|||||||
|
|
||||||
#if defined(HAS_SSL)
|
#if defined(HAS_SSL)
|
||||||
#if defined(SSL_AXTLS) || defined(ESP32)
|
#if defined(SSL_AXTLS) || defined(ESP32)
|
||||||
if(_client.isSSL && _fingerprint.length()) {
|
if(_client.isSSL && SSL_FINGERPRINT_IS_SET) {
|
||||||
if(!_client.ssl->verify(_fingerprint.c_str(), _host.c_str())) {
|
if(!_client.ssl->verify(_fingerprint.c_str(), _host.c_str())) {
|
||||||
DEBUG_WEBSOCKETS("[WS-Client] certificate mismatch\n");
|
DEBUG_WEBSOCKETS("[WS-Client] certificate mismatch\n");
|
||||||
WebSockets::clientDisconnect(&_client, 1000);
|
WebSockets::clientDisconnect(&_client, 1000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if(_client.isSSL && _fingerprint) {
|
if(_client.isSSL && SSL_FINGERPRINT_IS_SET) {
|
||||||
#endif
|
#endif
|
||||||
} else if(_client.isSSL && !_CA_cert) {
|
} else if(_client.isSSL && !_CA_cert) {
|
||||||
#if defined(SSL_BARESSL)
|
#if defined(SSL_BARESSL)
|
||||||
|
@ -112,12 +112,14 @@ class WebSocketsClient : protected WebSockets {
|
|||||||
#ifdef SSL_AXTLS
|
#ifdef SSL_AXTLS
|
||||||
String _fingerprint;
|
String _fingerprint;
|
||||||
const char * _CA_cert;
|
const char * _CA_cert;
|
||||||
|
#define SSL_FINGERPRINT_IS_SET (_fingerprint.length())
|
||||||
#define SSL_FINGERPRINT_NULL ""
|
#define SSL_FINGERPRINT_NULL ""
|
||||||
#else
|
#else
|
||||||
const uint8_t * _fingerprint;
|
const uint8_t * _fingerprint;
|
||||||
BearSSL::X509List * _CA_cert;
|
BearSSL::X509List * _CA_cert;
|
||||||
BearSSL::X509List * _client_cert;
|
BearSSL::X509List * _client_cert;
|
||||||
BearSSL::PrivateKey * _client_key;
|
BearSSL::PrivateKey * _client_key;
|
||||||
|
#define SSL_FINGERPRINT_IS_SET (_fingerprint != NULL)
|
||||||
#define SSL_FINGERPRINT_NULL NULL
|
#define SSL_FINGERPRINT_NULL NULL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user