mirror of
https://github.com/Links2004/arduinoWebSockets.git
synced 2025-07-19 10:12:06 +02:00
Add support for CA bundles (#885)
Why: - Allow CA cert bundles to be used This change addresses the need by: - Adding a constructor that takes a pointer to the bundle - Setting the WiFiClientSecure to use the bundle - Adding an example
This commit is contained in:
@ -48,6 +48,9 @@ void WebSocketsClient::begin(const char * host, uint16_t port, const char * url,
|
||||
#if defined(HAS_SSL)
|
||||
_fingerprint = SSL_FINGERPRINT_NULL;
|
||||
_CA_cert = NULL;
|
||||
#ifdef ESP32
|
||||
_CA_bundle = NULL;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
_client.num = 0;
|
||||
@ -107,6 +110,7 @@ void WebSocketsClient::beginSSL(const char * host, uint16_t port, const char * u
|
||||
_client.isSSL = true;
|
||||
_fingerprint = fingerprint;
|
||||
_CA_cert = NULL;
|
||||
_CA_bundle = NULL;
|
||||
}
|
||||
|
||||
void WebSocketsClient::beginSSL(String host, uint16_t port, String url, String fingerprint, String protocol) {
|
||||
@ -118,7 +122,16 @@ void WebSocketsClient::beginSslWithCA(const char * host, uint16_t port, const ch
|
||||
_client.isSSL = true;
|
||||
_fingerprint = SSL_FINGERPRINT_NULL;
|
||||
_CA_cert = CA_cert;
|
||||
_CA_bundle = NULL;
|
||||
}
|
||||
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);
|
||||
_client.isSSL = true;
|
||||
_fingerprint = SSL_FINGERPRINT_NULL;
|
||||
_CA_cert = NULL;
|
||||
_CA_bundle = CA_bundle;
|
||||
}
|
||||
|
||||
#else
|
||||
void WebSocketsClient::beginSSL(const char * host, uint16_t port, const char * url, const uint8_t * fingerprint, const char * protocol) {
|
||||
begin(host, port, url, protocol);
|
||||
@ -231,6 +244,11 @@ void WebSocketsClient::loop(void) {
|
||||
#else
|
||||
#error setCACert not implemented
|
||||
#endif
|
||||
#if defined(ESP32)
|
||||
} else if(_CA_bundle) {
|
||||
DEBUG_WEBSOCKETS("[WS-Client] setting CA bundle");
|
||||
_client.ssl->setCACertBundle(_CA_bundle);
|
||||
#endif
|
||||
#if defined(ESP32)
|
||||
} else if(!SSL_FINGERPRINT_IS_SET) {
|
||||
_client.ssl->setInsecure();
|
||||
|
Reference in New Issue
Block a user