mirror of
https://github.com/Links2004/arduinoWebSockets.git
synced 2025-07-14 07:46:30 +02:00
verify ssl certificate fingerprint
This commit is contained in:
@ -47,6 +47,7 @@ void WebSocketsClient::begin(const char *host, uint16_t port, const char * url)
|
||||
#if (WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266)
|
||||
_client.isSSL = false;
|
||||
_client.ssl = NULL;
|
||||
_client.fingerprint = NULL;
|
||||
#endif
|
||||
_client.cUrl = url;
|
||||
_client.cCode = 0;
|
||||
@ -79,6 +80,17 @@ void WebSocketsClient::beginSSL(const char *host, uint16_t port, const char * ur
|
||||
void WebSocketsClient::beginSSL(String host, uint16_t port, String url) {
|
||||
beginSSL(host.c_str(), port, url.c_str());
|
||||
}
|
||||
|
||||
void WebSocketsClient::beginSSL(const char *host, uint16_t port, const char * url, const char * fingerprint) {
|
||||
begin(host, port, url);
|
||||
_client.isSSL = true;
|
||||
_client.fingerprint = fingerprint;
|
||||
}
|
||||
|
||||
void WebSocketsClient::beginSSL(String host, uint16_t port, String url, const char * fingerprint) {
|
||||
beginSSL(host.c_str(), port, url.c_str());
|
||||
_client.fingerprint = fingerprint;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -124,6 +136,13 @@ void WebSocketsClient::loop(void) {
|
||||
|
||||
#if (WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266)
|
||||
_client.tcp->setNoDelay(true);
|
||||
|
||||
if (_client.isSSL && _client.fingerprint != NULL) {
|
||||
if (!(((WiFiClientSecure*)_client.tcp)->verify(_client.fingerprint, _host.c_str()))) {
|
||||
DEBUG_WEBSOCKETS("[WS-Client] certificate mismatch\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// send Header to Server
|
||||
|
Reference in New Issue
Block a user