mirror of
https://github.com/Links2004/arduinoWebSockets.git
synced 2025-07-06 04:06:30 +02:00
fix #896 ESP32 Arduino changed setCACertBundle args
This commit is contained in:
@ -112,7 +112,13 @@ void setup() {
|
|||||||
// server address, port and URL. This server can be flakey.
|
// server address, port and URL. This server can be flakey.
|
||||||
// Expected response: Request served by 0123456789abcdef
|
// Expected response: Request served by 0123456789abcdef
|
||||||
// webSocket.beginSslWithBundle("echo.websocket.org", 443, "/", rootca_crt_bundle_start, "");
|
// webSocket.beginSslWithBundle("echo.websocket.org", 443, "/", rootca_crt_bundle_start, "");
|
||||||
|
// ESP32 3.0.4 or higher needs the size of the bundle
|
||||||
|
// webSocket.beginSslWithBundle("echo.websocket.org", 443, "/", rootca_crt_bundle_start, sizeof(rootca_crt_bundle_start), "");
|
||||||
|
#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 4)
|
||||||
|
webSocket.beginSslWithBundle("echo.websocket.org", 443, "/", NULL, 0, "");
|
||||||
|
#else
|
||||||
webSocket.beginSslWithBundle("echo.websocket.org", 443, "/", NULL, "");
|
webSocket.beginSslWithBundle("echo.websocket.org", 443, "/", NULL, "");
|
||||||
|
#endif
|
||||||
|
|
||||||
// event handler
|
// event handler
|
||||||
webSocket.onEvent(webSocketEvent);
|
webSocket.onEvent(webSocketEvent);
|
||||||
|
@ -50,6 +50,9 @@ void WebSocketsClient::begin(const char * host, uint16_t port, const char * url,
|
|||||||
_CA_cert = NULL;
|
_CA_cert = NULL;
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
_CA_bundle = NULL;
|
_CA_bundle = NULL;
|
||||||
|
#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 4)
|
||||||
|
_CA_bundle_size = 0;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -124,6 +127,17 @@ void WebSocketsClient::beginSslWithCA(const char * host, uint16_t port, const ch
|
|||||||
_CA_cert = CA_cert;
|
_CA_cert = CA_cert;
|
||||||
_CA_bundle = NULL;
|
_CA_bundle = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(ESP32) && ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 4)
|
||||||
|
void WebSocketsClient::beginSslWithBundle(const char * host, uint16_t port, const char * url, const uint8_t * CA_bundle, size_t CA_bundle_size, const char * protocol) {
|
||||||
|
begin(host, port, url, protocol);
|
||||||
|
_client.isSSL = true;
|
||||||
|
_fingerprint = SSL_FINGERPRINT_NULL;
|
||||||
|
_CA_cert = NULL;
|
||||||
|
_CA_bundle = CA_bundle;
|
||||||
|
_CA_bundle_size = CA_bundle_size;
|
||||||
|
}
|
||||||
|
#else
|
||||||
void WebSocketsClient::beginSslWithBundle(const char * host, uint16_t port, const char * url, const uint8_t * CA_bundle, const char * protocol) {
|
void WebSocketsClient::beginSslWithBundle(const char * host, uint16_t port, const char * url, const uint8_t * CA_bundle, const char * protocol) {
|
||||||
begin(host, port, url, protocol);
|
begin(host, port, url, protocol);
|
||||||
_client.isSSL = true;
|
_client.isSSL = true;
|
||||||
@ -131,6 +145,7 @@ void WebSocketsClient::beginSslWithBundle(const char * host, uint16_t port, cons
|
|||||||
_CA_cert = NULL;
|
_CA_cert = NULL;
|
||||||
_CA_bundle = CA_bundle;
|
_CA_bundle = CA_bundle;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
void WebSocketsClient::beginSSL(const char * host, uint16_t port, const char * url, const uint8_t * fingerprint, const char * protocol) {
|
void WebSocketsClient::beginSSL(const char * host, uint16_t port, const char * url, const uint8_t * fingerprint, const char * protocol) {
|
||||||
@ -247,9 +262,11 @@ void WebSocketsClient::loop(void) {
|
|||||||
#if defined(ESP32)
|
#if defined(ESP32)
|
||||||
} else if(_CA_bundle) {
|
} else if(_CA_bundle) {
|
||||||
DEBUG_WEBSOCKETS("[WS-Client] setting CA bundle");
|
DEBUG_WEBSOCKETS("[WS-Client] setting CA bundle");
|
||||||
|
#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 4)
|
||||||
|
_client.ssl->setCACertBundle(_CA_bundle, _CA_bundle_size);
|
||||||
|
#else
|
||||||
_client.ssl->setCACertBundle(_CA_bundle);
|
_client.ssl->setCACertBundle(_CA_bundle);
|
||||||
#endif
|
#endif
|
||||||
#if defined(ESP32)
|
|
||||||
} else if(!SSL_FINGERPRINT_IS_SET) {
|
} else if(!SSL_FINGERPRINT_IS_SET) {
|
||||||
_client.ssl->setInsecure();
|
_client.ssl->setInsecure();
|
||||||
#elif defined(SSL_BARESSL)
|
#elif defined(SSL_BARESSL)
|
||||||
|
@ -54,8 +54,12 @@ class WebSocketsClient : protected WebSockets {
|
|||||||
#endif
|
#endif
|
||||||
void beginSslWithCA(const char * host, uint16_t port, const char * url = "/", const char * CA_cert = NULL, const char * protocol = "arduino");
|
void beginSslWithCA(const char * host, uint16_t port, const char * url = "/", const char * CA_cert = NULL, const char * protocol = "arduino");
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
|
#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 4)
|
||||||
|
void beginSslWithBundle(const char * host, uint16_t port, const char * url = "/", const uint8_t * CA_bundle = NULL, size_t CA_bundle_size = 0, const char * protocol = "arduino");
|
||||||
|
#else
|
||||||
void beginSslWithBundle(const char * host, uint16_t port, const char * url = "/", const uint8_t * CA_bundle = NULL, const char * protocol = "arduino");
|
void beginSslWithBundle(const char * host, uint16_t port, const char * url = "/", const uint8_t * CA_bundle = NULL, const char * protocol = "arduino");
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void beginSocketIO(const char * host, uint16_t port, const char * url = "/socket.io/?EIO=3", const char * protocol = "arduino");
|
void beginSocketIO(const char * host, uint16_t port, const char * url = "/socket.io/?EIO=3", const char * protocol = "arduino");
|
||||||
@ -116,6 +120,11 @@ class WebSocketsClient : protected WebSockets {
|
|||||||
String _fingerprint;
|
String _fingerprint;
|
||||||
const char * _CA_cert;
|
const char * _CA_cert;
|
||||||
const uint8_t * _CA_bundle;
|
const uint8_t * _CA_bundle;
|
||||||
|
#if defined(ESP32)
|
||||||
|
#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 4)
|
||||||
|
size_t _CA_bundle_size;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
#define SSL_FINGERPRINT_IS_SET (_fingerprint.length())
|
#define SSL_FINGERPRINT_IS_SET (_fingerprint.length())
|
||||||
#define SSL_FINGERPRINT_NULL ""
|
#define SSL_FINGERPRINT_NULL ""
|
||||||
#else
|
#else
|
||||||
|
Reference in New Issue
Block a user