1

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?

Community
  • 1
  • 1
Vitor Baptista
  • 2,016
  • 1
  • 23
  • 28

1 Answers1

3

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.

Marcel Stör
  • 22,695
  • 19
  • 92
  • 198
  • Oh! Do you know about any way to do this request, then? – Vitor Baptista Aug 28 '16 at 14:00
  • Yeah, it's the correct answer. We had this a couple of times on [our issues list](https://git.io/v6h6B) and here on SO. Until the SDK in NodeMCU uses [mbedTLS instead of axTLS](https://github.com/nodemcu/nodemcu-firmware/pull/1435#issuecomment-237364942) you can't make encrypted connections to httpbin.org. – Marcel Stör Aug 28 '16 at 14:13