IDF是v3.3,只要代码中调用了 .use_global_ca_store 这个变量就会提示找不到
app_main.c:133:10: error: 'esp_mqtt_client_config_t {aka struct <anonymous>}' has no member named 'use_global_ca_store'
但是我在头文件里是明确看到这一成员变量的,然后我在英文板块也看到有人反馈这个问题,麻烦官方看一下是哪里出错了
使用esp_mqtt_client_config_t的use_global_ca_store成员,编译出错
Re: 使用esp_mqtt_client_config_t的use_global_ca_store成员,编译出错
我重新拉取了最新的MQTT组件,目前可以编译了,但是跑WSS的demo会不断重启,提示如下:
请问一下这个use_global_ca_store到底怎么用的?连接WSS的mqtt是必须添加证书吗?
Code: Select all
I (4677) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (4687) MQTTWSS_EXAMPLE: Other event id:7
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x4012ff1b PS : 0x00060630 A0 : 0x800e7694 A1 : 0x3ffc88a0
0x4012ff1b: ip4addr_aton at /mnt/hgfs/workspace/esp32/IDF/esp-idf-v3.3/components/lwip/lwip/src/core/ipv4/ip4_addr.c:173
A2 : 0x00000000 A3 : 0x3ffc88d4 A4 : 0x00060020 A5 : 0x00000001
A6 : 0x00060020 A7 : 0x00000000 A8 : 0x800d31a2 A9 : 0x3ffc8880
A10 : 0x400deac8 A11 : 0x3ffb3cd4 A12 : 0x3f40369c A13 : 0x0000001f
0x400deac8: vprintf at /Users/ivan/e/newlib_xtensa-2.2.0-bin/newlib_xtensa-2.2.0/xtensa-esp32-elf/newlib/libc/stdio/../../../.././newlib/libc/stdio/vprintf.c:35
A14 : 0x00000001 A15 : 0x00000003 SAR : 0x00000004 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000000 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xfffffffb
ELF file SHA256: 3816237763bd30f6d735072ab74d2905bb97580e92da8c213967c6a1497a619f
Backtrace: 0x4012ff1b:0x3ffc88a0 0x400e7691:0x3ffc88d0 0x40154679:0x3ffc8910 0x400d38c7:0x3ffc8930 0x4008bf05:0x3ffc8950
0x4012ff1b: ip4addr_aton at /mnt/hgfs/workspace/esp32/IDF/esp-idf-v3.3/components/lwip/lwip/src/core/ipv4/ip4_addr.c:173
0x400e7691: tcp_connect at /mnt/hgfs/workspace/esp32/IDF/esp-idf-v3.3/components/tcp_transport/transport_tcp.c:61
0x40154679: esp_transport_connect at /mnt/hgfs/workspace/esp32/IDF/esp-idf-v3.3/components/tcp_transport/transport.c:163
0x400d38c7: esp_mqtt_task at /mnt/hgfs/workspace/esp32/IDF/esp-idf-v3.3/components/mqtt/esp-mqtt/mqtt_client.c:780
-
- Posts: 786
- Joined: Wed Nov 14, 2018 8:45 am
Re: 使用esp_mqtt_client_config_t的use_global_ca_store成员,编译出错
你先用默认的 wss example 试试,把 broker 改成 wss://test.mosquitto.org:8081/wss,不用改动代码。
有以下几种方式:
1. wss example 中默认是需要校验 CA 证书的,
const esp_mqtt_client_config_t mqtt_cfg = {
.uri = CONFIG_BROKER_URI,
.event_handle = mqtt_event_handler,
.cert_pem = (const char *)iot_eclipse_org_pem_start,
};
2. 可以不校验:
const esp_mqtt_client_config_t mqtt_cfg = {
.uri = CONFIG_BROKER_URI,
.event_handle = mqtt_event_handler,
};
3. 可以用一个全局的 CA 校验:
const esp_mqtt_client_config_t mqtt_cfg = {
.uri = CONFIG_BROKER_URI,
.event_handle = mqtt_event_handler,
.use_global_ca_store = true,
};
这种方式下,需要调用 esp_tls_set_global_ca_store 接口注册全局 CA,这个示例中可以是如下:
esp_tls_set_global_ca_store(iot_eclipse_org_pem_start, iot_eclipse_org_pem_end - iot_eclipse_org_pem_start);
注:在 esp_mqtt_client_init 之前调用,需要 #include "esp_tls.h"。
另外,不知道你是怎么改导致出这个 crash 的,提问时请尽量多的提供信息,以便分析。
有以下几种方式:
1. wss example 中默认是需要校验 CA 证书的,
const esp_mqtt_client_config_t mqtt_cfg = {
.uri = CONFIG_BROKER_URI,
.event_handle = mqtt_event_handler,
.cert_pem = (const char *)iot_eclipse_org_pem_start,
};
2. 可以不校验:
const esp_mqtt_client_config_t mqtt_cfg = {
.uri = CONFIG_BROKER_URI,
.event_handle = mqtt_event_handler,
};
3. 可以用一个全局的 CA 校验:
const esp_mqtt_client_config_t mqtt_cfg = {
.uri = CONFIG_BROKER_URI,
.event_handle = mqtt_event_handler,
.use_global_ca_store = true,
};
这种方式下,需要调用 esp_tls_set_global_ca_store 接口注册全局 CA,这个示例中可以是如下:
esp_tls_set_global_ca_store(iot_eclipse_org_pem_start, iot_eclipse_org_pem_end - iot_eclipse_org_pem_start);
注:在 esp_mqtt_client_init 之前调用,需要 #include "esp_tls.h"。
另外,不知道你是怎么改导致出这个 crash 的,提问时请尽量多的提供信息,以便分析。
Who is online
Users browsing this forum: No registered users and 36 guests