HTTPS get requests with NodeMCU and ESP8266

若如初见. 提交于 2019-12-24 07:35:04

问题


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.

The code I'm trying is:

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
);

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>.

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)

What am I doing wrong?


回答1:


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.

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://stackoverflow.com/questions/39189745/https-get-requests-with-nodemcu-and-esp8266

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!