19
19
#include "nvs_flash.h"
20
20
#include "esp_event.h"
21
21
#include "protocol_examples_common.h"
22
+ #include "esp_crt_bundle.h"
22
23
23
24
#include "freertos/FreeRTOS.h"
24
25
#include "freertos/task.h"
@@ -145,6 +146,14 @@ static void websocket_app_start(void)
145
146
websocket_cfg .uri = CONFIG_WEBSOCKET_URI ;
146
147
#endif /* CONFIG_WEBSOCKET_URI_FROM_STDIN */
147
148
149
+ #if CONFIG_WS_OVER_TLS_SERVER_AUTH || CONFIG_WS_OVER_TLS_MUTUAL_AUTH
150
+ // Using certificate bundle as default server certificate source
151
+ websocket_cfg .crt_bundle_attach = esp_crt_bundle_attach ;
152
+ // If using a custom certificate it could be added to certificate bundle, added to the build simmilar to client certificates in this examples,
153
+ // or read from NVS.
154
+ /* extern const char cacert_start[] asm("ADDED_CERTIFICATE"); */
155
+ /* websocket_cfg.cert_pem = cacert_start; */
156
+ #endif
148
157
#if CONFIG_WS_OVER_TLS_MUTUAL_AUTH
149
158
/* Configuring client certificates for mutual authentification */
150
159
extern const char cacert_start [] asm("_binary_ca_cert_pem_start" ); // CA certificate
@@ -158,9 +167,6 @@ static void websocket_app_start(void)
158
167
websocket_cfg .client_cert_len = cert_end - cert_start ;
159
168
websocket_cfg .client_key = key_start ;
160
169
websocket_cfg .client_key_len = key_end - key_start ;
161
- #elif CONFIG_WS_OVER_TLS_SERVER_AUTH
162
- extern const char cacert_start [] asm("_binary_ca_certificate_public_domain_pem_start" ); // CA cert of wss://echo.websocket.event, modify it if using another server
163
- websocket_cfg .cert_pem = cacert_start ;
164
170
#endif
165
171
166
172
#if CONFIG_WS_OVER_TLS_SKIP_COMMON_NAME_CHECK
0 commit comments