我在ESP8266上使用nodemcu连接到MQTT代理,并想使用TLS。我正在使用test.mosquitto.org进行测试。我发现可以使用TLS连接到它,但是当我使用提供的证书验证代理时,它无法连接。我收到错误代码-5,它是mqtt.CONN_FAIL_SERVER_NOT_FOUND。我发现使用相同证书的Python / Paho验证工作正常。我在做错什么吗?
NodeMCU custom build by frightanic.com
branch: master
commit: 11592951b90707cdcb6d751876170bf4da82850d
SSL: true
modules: crypto,file,gpio,mqtt,net,node,rtcfifo,rtcmem,rtctime,sjson,tmr,uart,wifi,tls
build created on 2019-01-23 05:04
powered by Lua 5.1.4 on SDK 2.2.1(6ab97e9)
lua: cannot open init.lua
>
>
> =tls.cert.verify([[-----BEGIN CERTIFICATE-----
>> MIIC8DCCAlmgAwIBAgIJAOD63PlXjJi8MA0GCSqGSIb3DQEBBQUAMIGQMQswCQYD
>> VQQGEwJHQjEXMBUGA1UECAwOVW5pdGVkIEtpbmdkb20xDjAMBgNVBAcMBURlcmJ5
>> MRIwEAYDVQQKDAlNb3NxdWl0dG8xCzAJBgNVBAsMAkNBMRYwFAYDVQQDDA1tb3Nx
>> dWl0dG8ub3JnMR8wHQYJKoZIhvcNAQkBFhByb2dlckBhdGNob28ub3JnMB4XDTEy
>> MDYyOTIyMTE1OVoXDTIyMDYyNzIyMTE1OVowgZAxCzAJBgNVBAYTAkdCMRcwFQYD
>> VQQIDA5Vbml0ZWQgS2luZ2RvbTEOMAwGA1UEBwwFRGVyYnkxEjAQBgNVBAoMCU1v
>> c3F1aXR0bzELMAkGA1UECwwCQ0ExFjAUBgNVBAMMDW1vc3F1aXR0by5vcmcxHzAd
>> BgkqhkiG9w0BCQEWEHJvZ2VyQGF0Y2hvby5vcmcwgZ8wDQYJKoZIhvcNAQEBBQAD
>> gY0AMIGJAoGBAMYkLmX7SqOT/jJCZoQ1NWdCrr/pq47m3xxyXcI+FLEmwbE3R9vM
>> rE6sRbP2S89pfrCt7iuITXPKycpUcIU0mtcT1OqxGBV2lb6RaOT2gC5pxyGaFJ+h
>> A+GIbdYKO3JprPxSBoRponZJvDGEZuM3N7p3S/lRoi7G5wG5mvUmaE5RAgMBAAGj
>> UDBOMB0GA1UdDgQWBBTad2QneVztIPQzRRGj6ZHKqJTv5jAfBgNVHSMEGDAWgBTa
>> d2QneVztIPQzRRGj6ZHKqJTv5jAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUA
>> A4GBAAqw1rK4NlRUCUBLhEFUQasjP7xfFqlVbE2cRy0Rs4o3KS0JwzQVBwG85xge
>> REyPOFdGdhBY2P1FNRy0MDr6xr+D2ZOwxs63dG1nnAnWZg7qwoLgpZ4fESPD3PkA
>> 1ZgKJc2zbSQ9fCPxt2W3mdVav66c6fsb7els2W2Iz7gERJSX
>> -----END CERTIFICATE-----]])
true
>
>
> =tls.cert.verify(true)
true
> sntp.sync('pool.ntp.org',
>> function(sec, usec, server)
>> print("Clock Synced: "..sec..", "..usec..", "..server)
>> end,
>> function(error_code)
>> print("Clock Sync Failed: "..sntp_connect_status_codes[error_code])
>> end
>> )
> Clock Synced: 1548219962, 492942, 12.167.151.1
> MQTTClient = mqtt.Client("clientid", 120)
>
> MQTTClient:connect("test.mosquitto.org", 8883, 1, function(c) print("connected") end, function (client, reason) print("error", reason) end)
> error -5