mqtt ssl双向认证例程报-0x2700错误![IDFGH-2945]
Posted: Mon Mar 23, 2020 9:21 am
版本idf-3.2,example/protocols/mqtt/ssl_mutual_aut例程,客户端认证正常,加人服务器认证后报-0x2700错误。
错误信息:
E (1193558) esp-tls: mbedtls_ssl_handshake returned -0x2700
I (1193558) esp-tls: Failed to verify peer certificate!
I (1193558) esp-tls: verification info: ! The certificate is signed with an unacceptable key (eg bad curve, RSA too short).
E (1193578) esp-tls: Failed to open new connection
E (1193578) TRANS_SSL: Failed to open a new connection
E (1193588) MQTT_CLIENT: Error transport connect
证书定义:
extern const uint8_t client_cert_pem_start[] asm("_binary_client_crt_start");
extern const uint8_t client_cert_pem_end[] asm("_binary_client_crt_end");
extern const uint8_t client_key_pem_start[] asm("_binary_client_key_start");
extern const uint8_t client_key_pem_end[] asm("_binary_client_key_end");
extern const uint8_t server_cert_pem_start[] asm("_binary_mosquitto_org_crt_start");
extern const uint8_t server_cert_pem_end[] asm("_binary_mosquitto_org_crt_end")
mqtt配置:
const esp_mqtt_client_config_t mqtt_cfg = {
.uri = "mqtts://test.mosquitto.org:8884",
.event_handle = mqtt_event_handler,
.cert_pem = (const char *)server_cert_pem_start,
.client_cert_pem = (const char *)client_cert_pem_start,
.client_key_pem = (const char *)client_key_pem_start,
};
证书地址:
https://test.mosquitto.org/ssl/mosquitto.org.crt
mk文件:
COMPONENT_EMBED_TXTFILES := client.crt client.key mosquitto.org.crt
错误信息:
E (1193558) esp-tls: mbedtls_ssl_handshake returned -0x2700
I (1193558) esp-tls: Failed to verify peer certificate!
I (1193558) esp-tls: verification info: ! The certificate is signed with an unacceptable key (eg bad curve, RSA too short).
E (1193578) esp-tls: Failed to open new connection
E (1193578) TRANS_SSL: Failed to open a new connection
E (1193588) MQTT_CLIENT: Error transport connect
证书定义:
extern const uint8_t client_cert_pem_start[] asm("_binary_client_crt_start");
extern const uint8_t client_cert_pem_end[] asm("_binary_client_crt_end");
extern const uint8_t client_key_pem_start[] asm("_binary_client_key_start");
extern const uint8_t client_key_pem_end[] asm("_binary_client_key_end");
extern const uint8_t server_cert_pem_start[] asm("_binary_mosquitto_org_crt_start");
extern const uint8_t server_cert_pem_end[] asm("_binary_mosquitto_org_crt_end")
mqtt配置:
const esp_mqtt_client_config_t mqtt_cfg = {
.uri = "mqtts://test.mosquitto.org:8884",
.event_handle = mqtt_event_handler,
.cert_pem = (const char *)server_cert_pem_start,
.client_cert_pem = (const char *)client_cert_pem_start,
.client_key_pem = (const char *)client_key_pem_start,
};
证书地址:
https://test.mosquitto.org/ssl/mosquitto.org.crt
mk文件:
COMPONENT_EMBED_TXTFILES := client.crt client.key mosquitto.org.crt