HTTPS通过NodeMCU和ESP8266获取请求 [英] HTTPS get requests with NodeMCU and ESP8266
问题描述
我在使用NodeMCU进行HTTPS GET请求时遇到问题,即使根据他们的文档和这个答案在StackOverflow上。
I'm having problems doing a HTTPS GET request with NodeMCU, even though it seems it should be possible according to their documentations and this answer here on StackOverflow.
我正在尝试的代码是:
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>
。
This gets me the result: -1 nil
. If I change the URL from https://httpbin.org/get
to http://httpbin.org/get
, I get the expected result 200 <RESPONSE>
.
我的NodeMCU构建为:
My NodeMCU build is:
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)
我在做什么错了?
推荐答案
您没有做错任何事情。如果您使用启用了DEBUG的固件来执行此操作,则会看到SSL握手失败。
You're not doing anything wrong. If you did this with a firmware that's got DEBUG enabled you'd see that the SSL handshake fails.
Espressif SDK随附的SSL库仅支持 4个密码套件。它们都不在httpbin.org支持的SSL证书的密码列表中。
The SSL library shipped with the Espressif SDK supports only 4 cipher suites. Neither of them are in the list of ciphers the SSL certificate used by httpbin.org supports.
这篇关于HTTPS通过NodeMCU和ESP8266获取请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!