Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tls验证openssl CA证书失败 #86

Open
feihualuomeng opened this issue Jun 2, 2023 · 3 comments
Open

tls验证openssl CA证书失败 #86

feihualuomeng opened this issue Jun 2, 2023 · 3 comments

Comments

@feihualuomeng
Copy link

mbedtls认证X509证书总是失败nettype_tls.c:30 server_certificate_verify()... server_certificate_verify failed returned 0x0004,用mqttBox客户端可以正常连接到服务器,是不是不能使用自签名的证书啊

@jiejieTop
Copy link
Owner

这个应该是代码中mbedtls没处理正确,我之前有发现这个问题

@ThomasVon2021
Copy link

root@63a364bdf4db:~/service/mqttclient-master/mqttclient-master/build# ./bin/emqx_example

welcome to mqttclient test...

[E] >> /root/service/mqttclient-master/mqttclient-master/network/nettype_tls.c:30 server_certificate_verify()... server_certificate_verify failed returned 0x0008

[E] >> /root/service/mqttclient-master/mqttclient-master/network/nettype_tls.c:149 nettype_tls_connect()...mbedtls handshake failed returned 0x0008
[I] >> /root/service/mqttclient-master/mqttclient-master/mqttclient/mqttclient.c:1473 mqtt_list_subscribe_topic()... there are no subscribed topics..
是的,请问可以修复一下此bug吗,我也发现了类似的问题

@iamlook
Copy link

iamlook commented Aug 11, 2023

这是因为 nettype_tls_init 的时候用 传入的host(服务器地址) 来初始化 ssl 的hostname了 mbedtls_ssl_set_hostname .
而ssl里面的hostname是mbedtls用来校验证书的CN的, 所以合理的方法是给 mqtt_client_t 加上一个 ca_cn 之类的成员用来在初始化的时候传入多一个发证机构名, 然后用这个名字来 mbedtls_ssl_set_hostname .
如果你证书是自己写死的, 可以干脆不去 verify 了.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants