我在使用NodeMCU执行HTTPS GET请求时遇到问题,即使它看起来应该可以根据他们的文档和StackOverflow上的this answer来实现 .
我正在尝试的代码是:
function getHTTPS()
http.get('https://httpbin.org/get', nil, function(code, data)
print(code, data)
end)
end
enduser_setup.start(
function()
print("Connected to wifi as: " .. wifi.sta.getip())
getHTTPS()
end,
function(err, str)
print("enduser_setup: Err #" .. err .. ": " .. str)
end
);
这让我得到了结果: -1 nil
. 如果我将URL从 https://httpbin.org/get
更改为 http://httpbin.org/get
,我会得到预期的结果 200 <RESPONSE>
.
我的NodeMCU构建是:
NodeMCU custom build by frightanic.com
branch: master
commit: 95e85c74e7310a595aa6bd57dbbc69ec3516e9c6
SSL: true
modules: cjson,enduser_setup,file,gpio,http,mdns,net,node,tmr,uart,wifi build
built on: 2016-08-27 07:36
powered by Lua 5.1.4 on SDK 1.5.4.1(39cb9a32)
我究竟做错了什么?
1 回答
你没有做错任何事 . 如果您使用已启用DEBUG的固件执行此操作,您将看到SSL握手失败 .
Espressif SDK附带的SSL库仅支持4 cipher suites . 它们都不在httpbin.org支持的SSL证书的密码列表中 .