@@ -128,6 +128,12 @@ void WebSocketsClient::beginSslWithCA(const char * host, uint16_t port, const ch
128128 _CA_bundle = NULL ;
129129}
130130
131+ void WebSocketsClient::beginSslWithClientKey (const char * host, uint16_t port, const char * url, const char * CA_cert, const char * clientCert, const char * clientPrivateKey, const char * protocol) {
132+ _client_cert = clientCert;
133+ _client_key = clientPrivateKey;
134+ beginSslWithCA (host, port, url, CA_cert, protocol);
135+ }
136+
131137#if defined(ESP32) && ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 4)
132138void WebSocketsClient::beginSslWithBundle (const char * host, uint16_t port, const char * url, const uint8_t * CA_bundle, size_t CA_bundle_size, const char * protocol) {
133139 begin (host, port, url, protocol);
@@ -256,8 +262,13 @@ void WebSocketsClient::loop(void) {
256262 _client.ssl = new WEBSOCKETS_NETWORK_SSL_CLASS ();
257263 _client.tcp = _client.ssl ;
258264 if (_CA_cert) {
259- DEBUG_WEBSOCKETS (" [WS-Client] setting CA certificate" );
265+ DEBUG_WEBSOCKETS (" [WS-Client] setting CA certificate\n " );
260266#if defined(ESP32)
267+ if (_client_cert && _client_key) {
268+ _client.ssl ->setCertificate (_client_cert);
269+ _client.ssl ->setPrivateKey (_client_key);
270+ DEBUG_WEBSOCKETS (" [WS-Client] no client certificate and key set\n " );
271+ }
261272 _client.ssl ->setCACert (_CA_cert);
262273#elif defined(ESP8266) && defined(SSL_AXTLS)
263274 _client.ssl ->setCACert ((const uint8_t *)_CA_cert, strlen (_CA_cert) + 1 );
@@ -272,7 +283,7 @@ void WebSocketsClient::loop(void) {
272283#endif
273284#if defined(ESP32)
274285 } else if (_CA_bundle) {
275- DEBUG_WEBSOCKETS (" [WS-Client] setting CA bundle" );
286+ DEBUG_WEBSOCKETS (" [WS-Client] setting CA bundle\n " );
276287#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 4)
277288 _client.ssl ->setCACertBundle (_CA_bundle, _CA_bundle_size);
278289#else
@@ -288,7 +299,7 @@ void WebSocketsClient::loop(void) {
288299 }
289300 if (_client_cert && _client_key) {
290301 _client.ssl ->setClientRSACert (_client_cert, _client_key);
291- DEBUG_WEBSOCKETS (" [WS-Client] setting client certificate and key" );
302+ DEBUG_WEBSOCKETS (" [WS-Client] setting client certificate and key\n " );
292303#endif
293304 }
294305 } else {
0 commit comments