[已解决]mbedtls_ssl_handshake错误导致添加设备失败

Wi-Fi 设备、Wi-Fi 低功耗设备、Wi-Fi BLE 双模设备、Ethernet设备、Ethernet+Wi-Fi设备等
shb3014
Posts: 17

设备已经成功完成了配网过程并获取了IP,但在接下来的激活过程中报 mbedtls_ssl_handshake returned 7200 -29184 这个错误,并不断重试,最终导致添加设备失败。MBEDTLS_SSL_MAX_CONTENT_LEN 为 16384,有尝试过将tuya_iot_config.h中的OPERATING_SYSTEM设置为101以保证其他头文件中该值均为最大,但结果一样。有尝试更换UUID和秘钥,但结果一样。

以下为获取IP后的部分log:

Code: Select all

I (17627) tcpip_adapter: sta ip: 192.168.31.52, mask: 255.255.255.0, gw: 192.168.31.1
I (17627) wifi station: Got IP:192.168.31.52
I (17951) wifi: Set ps type: 1

[01-01 18:12:31 TUYA D][tuya_tls.c:319] load tls_ca_cnt fail. no ca in local db
[01-01 18:12:31 TUYA D][iot_httpc.c:1179] http_iot_dns_get_cloud_url start
[01-01 18:12:31 TUYA D][iot_httpc.c:1204] sign_buffer:env=3WFj&region=AY&ts=16&uuid=uuid3d52871c9ec1b1f3
[01-01 18:12:31 TUYA D][iot_httpc.c:1212] sign_base64_encode:ddI7jjpLitE6tEgIBxA3qp/Fxu/mx4wk6MyLU5+RrtA=
[01-01 18:12:31 TUYA D][uni_network.c:417] set_dns_region:1
[01-01 18:12:31 TUYA D][iot_httpc.c:1283] http_dns send: {"region":"AY","env":"3WFj","uuid":"xxxxxxxxxxx","ts":16,"sign":"ddI7jjpLitE6tEgIBxA3qp/Fxu/mx4wk6MyLU5+RrtA=","config":[{"key":"httpUrl","need_ca":false},{"key":"mqttUrl","need_ca":false},{"key":"httpsSelfUrl","need_ca":true},{"key":"mqttsSelfUrl","need_ca":true}]}
[01-01 18:12:31 TUYA D][iot_httpc.c:1288] get url config:https://h2.iot-dns.com/v2/url_config
[01-01 18:12:31 TUYA D][tuya_tls.c:376] tls register constant xxxxxxx xxxxxxx
[01-01 18:12:31 TUYA D][httpc.c:813] Connect: h2.iot-dns.com Port: 443  -->>
[01-01 18:12:31 TUYA D][uni_network.c:314] unw_gethostbyname h2.iot-dns.com, prio 2

[01-01 18:12:31 TUYA D][uni_network.c:365] use system dns ip 42.192.31.222 for domain h2.iot-dns.com

[01-01 18:12:31 TUYA D][uni_network.c:268] cache dns [h2.iot-dns.com]<->[42.192.31.222]
[01-01 18:12:31 TUYA D][httpc.c:477] ----got ipaddr:42,192,31,222
[01-01 18:12:31 TUYA D][httpc.c:815] Connect: h2.iot-dns.com Port: 443  --<< ,r:0
[01-01 18:12:31 TUYA D][tuya_tls.c:1269] ----enable_cert:1,DEFAULT_LOAD_CERT:1
[01-01 18:12:31 TUYA D][tuya_tls.c:1312] TUYA_TLS Begin Connect h2.iot-dns.com:443  CustomNet:TRUE Enable_Cert:TRUE Default:TRUE 
[01-01 18:12:31 TUYA D][tuya_tls.c:1387] load tuya cert.
[01-01 18:12:31 TUYA D][tuya_iot_com_api.c:271] tuya iot dns
[01-01 18:12:31 TUYA D][tuya_tls.c:1503] socket fd is set. set to inner send/recv to handshake
[01-01 18:12:31 TUYA D][tuya_tls.c:1519] tls handshake ret:0x7200, flags:0
[01-01 18:12:31 TUYA E][tuya_tls.c:1541] mbedtls_ssl_handshake returned 7200 -29184
[01-01 18:12:31 TUYA D][tuya_tls.c:1643] TUYA_TLS Disconnect ENTER
[01-01 18:12:31 TUYA D][tuya_tls.c:1698] TUYA_TLS Disconnect Success
[01-01 18:12:31 TUYA E][http_inf.c:51] Open session failed: https://h2.iot-dns.com/v2/url_config (-8)
[01-01 18:12:31 TUYA E][iot_httpc.c:1299] fail to get cloud url -2050
[01-01 18:12:32 TUYA D][tuya_iot_wifi_api.c:381] wifi netstat changed to:6  -->>
[01-01 18:12:32 TUYA N][tuya_device.c:439] wf_nw_status_cb, wifi_status:6
[01-01 18:12:32 TUYA D][tuya_iot_wifi_api.c:384] wifi netstat changed to:6  <<--
[01-01 18:12:32 TUYA D][app_agent.c:698] udp ip: 192.168.31.52
[01-01 18:12:32 TUYA D][tuya_tls.c:319] load tls_ca_cnt fail. no ca in local db
[01-01 18:12:32 TUYA D][iot_httpc.c:1179] http_iot_dns_get_cloud_url start
[01-01 18:12:32 TUYA D][iot_httpc.c:1204] sign_buffer:env=3WFj&region=AY&ts=17&uuid=xxxxxxx
[01-01 18:12:32 TUYA D][iot_httpc.c:1212] sign_base64_encode:J/25ln6ySrlJd6DyGF7fcTljJjH+uWMh4Efs9hGhHYw=
[01-01 18:12:32 TUYA D][uni_network.c:417] set_dns_region:1
[01-01 18:12:32 TUYA D][iot_httpc.c:1283] http_dns send: {"region":"AY","env":"3WFj","uuid":"uuid3d52871c9ec1b1f3","ts":17,"sign":"J/25ln6ySrlJd6DyGF7fcTljJjH+uWMh4Efs9hGhHYw=","config":[{"key":"httpUrl","need_ca":false},{"key":"mqttUrl","need_ca":false},{"key":"httpsSelfUrl","need_ca":true},{"key":"mqttsSelfUrl","need_ca":true}]}
[01-01 18:12:32 TUYA D][iot_httpc.c:1288] get url config:https://h2.iot-dns.com/v2/url_config
[01-01 18:12:32 TUYA D][tuya_tls.c:376] tls register constant xxxxx xxxx
[01-01 18:12:32 TUYA D][httpc.c:813] Connect: h2.iot-dns.com Port: 443  -->>
[01-01 18:12:32 TUYA D][uni_network.c:314] unw_gethostbyname h2.iot-dns.com, prio 2

[01-01 18:12:32 TUYA D][uni_network.c:353] use dynamic dns ip:42.192.31.222 for domain:h2.iot-dns.com
[01-01 18:12:32 TUYA D][httpc.c:477] ----got ipaddr:42,192,31,222
[01-01 18:12:32 TUYA D][httpc.c:815] Connect: h2.iot-dns.com Port: 443  --<< ,r:0
[01-01 18:12:32 TUYA D][tuya_tls.c:1269] ----enable_cert:1,DEFAULT_LOAD_CERT:1
[01-01 18:12:32 TUYA D][tuya_tls.c:1312] TUYA_TLS Begin Connect h2.iot-dns.com:443  CustomNet:TRUE Enable_Cert:TRUE Default:TRUE 
[01-01 18:12:32 TUYA D][tuya_tls.c:1387] load tuya cert.
[01-01 18:12:32 TUYA D][tuya_iot_com_api.c:271] tuya iot dns
[01-01 18:12:32 TUYA D][tuya_tls.c:1503] socket fd is set. set to inner send/recv to handshake
[01-01 18:12:33 TUYA D][tuya_tls.c:1519] tls handshake ret:0x7200, flags:0
[01-01 18:12:33 TUYA E][tuya_tls.c:1541] mbedtls_ssl_handshake returned 7200 -29184

感谢!


Tags:
愚者千虑必有一得
Posts: 426

Re: mbedtls_ssl_handshake错误导致添加设备失败

能发一下你的sdk压缩包的完整名称嘛?

修改配置是不生效的,我们的代码已经编译成库了,那些宏修改了也不会有作用。

shb3014
Posts: 17

Re: mbedtls_ssl_handshake错误导致添加设备失败

愚者千虑必有一得 2022年 Dec 16日 18:22

能发一下你的sdk压缩包的完整名称嘛?

修改配置是不生效的,我们的代码已经编译成库了,那些宏修改了也不会有作用。

多谢回复。包名是ty_iot_sdk_custom_esp32-series_2.3.2。我也不确定是不是MBEDTLS_SSL_MAX_CONTENT_LEN不足导致的问题。

shb3014
Posts: 17

Re: mbedtls_ssl_handshake错误导致添加设备失败

愚者千虑必有一得 2022年 Dec 16日 18:22

能发一下你的sdk压缩包的完整名称嘛?

修改配置是不生效的,我们的代码已经编译成库了,那些宏修改了也不会有作用。

我尝试直接打开https://h2.iot-dns.com/v2/url_config显示ca证书失效。尝试将h2换为h1-h5,仅h1.iot-dns.com证书有效,于是在tuya_os_adapt_net_gethostbyname中将域名强制改成了h1,改完后改报0x7280错误(换为其他的仍报0x7200)。

愚者千虑必有一得
Posts: 426

Re: mbedtls_ssl_handshake错误导致添加设备失败

shb3014 2022年 Dec 19日 13:49
愚者千虑必有一得 2022年 Dec 16日 18:22

能发一下你的sdk压缩包的完整名称嘛?

修改配置是不生效的,我们的代码已经编译成库了,那些宏修改了也不会有作用。

我尝试直接打开https://h2.iot-dns.com/v2/url_config显示ca证书失效。尝试将h2换为h1-h5,仅h1.iot-dns.com证书有效,于是在tuya_os_adapt_net_gethostbyname中将域名强制改成了h1,改完后改报0x7280错误(换为其他的仍报0x7200)。

我看了下,这个sdk是使用ecc证书模式的,只能访问h2.iot-dns.com,又是rtos系统,确实可能是buffer不足的问题。你们是必须要使用ecc证书模式吗?

另外ty_iot_sdk_custom_esp32-series_2.3.2是全名吗?能把tuya_iot_config.h有/* custom settings */那段代码截图发我看看嘛?

shb3014
Posts: 17

Re: mbedtls_ssl_handshake错误导致添加设备失败

愚者千虑必有一得 2022年 Dec 19日 18:28
shb3014 2022年 Dec 19日 13:49
愚者千虑必有一得 2022年 Dec 16日 18:22

能发一下你的sdk压缩包的完整名称嘛?

修改配置是不生效的,我们的代码已经编译成库了,那些宏修改了也不会有作用。

我尝试直接打开https://h2.iot-dns.com/v2/url_config显示ca证书失效。尝试将h2换为h1-h5,仅h1.iot-dns.com证书有效,于是在tuya_os_adapt_net_gethostbyname中将域名强制改成了h1,改完后改报0x7280错误(换为其他的仍报0x7200)。

我看了下,这个sdk是使用ecc证书模式的,只能访问h2.iot-dns.com,又是rtos系统,确实可能是buffer不足的问题。你们是必须要使用ecc证书模式吗?

另外ty_iot_sdk_custom_esp32-series_2.3.2是全名吗?能把tuya_iot_config.h有/* custom settings */那段代码截图发我看看嘛?

您好,我不太懂证书这块,RSA或其他模式的证书应该也是可以的,在esp32上RSA模式的速度似乎还更快一些。
我们拿到的压缩包名是“ffcaca90-3fc9-11ed-9d99-a5aaf2a10702-1664437233081.tar.gz”。解压后文件夹名是“ty_iot_sdk_custom_esp32-series_2.3.2”。
以下是custom settings的部分,附件是完整的tuya_iot_config.h文件。

Code: Select all

/* custom settings */
#define BUILD_DATE    "2022_09_29"
#define BUILD_TIME    "11_36_59"
#define GIT_USER    "ci_manage"
#define IOT_SDK_VER    "2.3.2"
#define SDK_BETA_VER    "beta.96"
#define PROJECT_NAME    "ty_iot_sdk_custom"
#define TARGET_PLATFORM    "esp32-series"
#define SDK_ID    "TuyaOS2.3.2_ty_iot_sdk_custom_2.3.2-beta.96_esp32-series_default_0.0.1-beta.0"
// Generated by Tuya (https://www.tuya.com)

十分感谢!

Attachments
tuya_iot_config.h
(7.41 KiB) Downloaded 54 times
shb3014
Posts: 17

Re: mbedtls_ssl_handshake错误导致添加设备失败

愚者千虑必有一得 2022年 Dec 19日 18:28
shb3014 2022年 Dec 19日 13:49
愚者千虑必有一得 2022年 Dec 16日 18:22

能发一下你的sdk压缩包的完整名称嘛?

修改配置是不生效的,我们的代码已经编译成库了,那些宏修改了也不会有作用。

我尝试直接打开https://h2.iot-dns.com/v2/url_config显示ca证书失效。尝试将h2换为h1-h5,仅h1.iot-dns.com证书有效,于是在tuya_os_adapt_net_gethostbyname中将域名强制改成了h1,改完后改报0x7280错误(换为其他的仍报0x7200)。

我看了下,这个sdk是使用ecc证书模式的,只能访问h2.iot-dns.com,又是rtos系统,确实可能是buffer不足的问题。你们是必须要使用ecc证书模式吗?

另外ty_iot_sdk_custom_esp32-series_2.3.2是全名吗?能把tuya_iot_config.h有/* custom settings */那段代码截图发我看看嘛?

麻烦请教您一下,这个我们有办法自己解决吗,还是需要您那边帮我们重新打包一份SDK。感谢。

愚者千虑必有一得
Posts: 426

Re: mbedtls_ssl_handshake错误导致添加设备失败

shb3014 2022年 Dec 21日 15:48
愚者千虑必有一得 2022年 Dec 19日 18:28
shb3014 2022年 Dec 19日 13:49

我尝试直接打开https://h2.iot-dns.com/v2/url_config显示ca证书失效。尝试将h2换为h1-h5,仅h1.iot-dns.com证书有效,于是在tuya_os_adapt_net_gethostbyname中将域名强制改成了h1,改完后改报0x7280错误(换为其他的仍报0x7200)。

我看了下,这个sdk是使用ecc证书模式的,只能访问h2.iot-dns.com,又是rtos系统,确实可能是buffer不足的问题。你们是必须要使用ecc证书模式吗?

另外ty_iot_sdk_custom_esp32-series_2.3.2是全名吗?能把tuya_iot_config.h有/* custom settings */那段代码截图发我看看嘛?

麻烦请教您一下,这个我们有办法自己解决吗,还是需要您那边帮我们重新打包一份SDK。感谢。

今天我给你更新一个sdk。

shb3014
Posts: 17

Re: mbedtls_ssl_handshake错误导致添加设备失败

愚者千虑必有一得 2022年 Dec 22日 15:01
shb3014 2022年 Dec 21日 15:48
愚者千虑必有一得 2022年 Dec 19日 18:28

我看了下,这个sdk是使用ecc证书模式的,只能访问h2.iot-dns.com,又是rtos系统,确实可能是buffer不足的问题。你们是必须要使用ecc证书模式吗?

另外ty_iot_sdk_custom_esp32-series_2.3.2是全名吗?能把tuya_iot_config.h有/* custom settings */那段代码截图发我看看嘛?

麻烦请教您一下,这个我们有办法自己解决吗,还是需要您那边帮我们重新打包一份SDK。感谢。

今天我给你更新一个sdk。

好的,非常感谢!

shb3014
Posts: 17

Re: mbedtls_ssl_handshake错误导致添加设备失败

愚者千虑必有一得 2022年 Dec 22日 15:01
shb3014 2022年 Dec 21日 15:48
愚者千虑必有一得 2022年 Dec 19日 18:28

我看了下,这个sdk是使用ecc证书模式的,只能访问h2.iot-dns.com,又是rtos系统,确实可能是buffer不足的问题。你们是必须要使用ecc证书模式吗?

另外ty_iot_sdk_custom_esp32-series_2.3.2是全名吗?能把tuya_iot_config.h有/* custom settings */那段代码截图发我看看嘛?

麻烦请教您一下,这个我们有办法自己解决吗,还是需要您那边帮我们重新打包一份SDK。感谢。

今天我给你更新一个sdk。

您好,我这边再补充一个信息,我们将MBEDTLS_SSL_MAX_CONTENT_LEN分别设为16384, 6144和1024后,在设备连上wifi后,我们自己根据log中的参数向https://h2.iot-dns.com/v2/url_config发送https get请求均可以成功,所以我们怀疑可能不是buffer大小的问题。感谢!

Post Reply