0
votes
conn=net.createConnection(net.TCP, 1)
conn:on("receive", function(sck, c) print(c) end )
conn:on("connection", function(conn)
      print("connected")
conn= net.cert.verify([[
-----BEGIN CERTIFICATE-----
0‚ 0‚‰ 5ÞôÏ0
     *†H†÷
 0N10     UUS10U
Equifax1-0+U$Equifax Secure Certificate Authority0
980822164151Z
180822164151Z0N10  UUS10U
Equifax1-0+U$Equifax Secure Certificate Authority0Ÿ0
    *†H†÷
  0‰ Á]±Xgbî š-m‘h˜
þÚo„b!ÃÑ|Οà¸ðN4ì⊕d¬ñkS_³Ëg€¿BŽþÝ ìá OüûðÝCº[+á€p™W“ñ—j·Âh#ÌMY0¬Q;¯+ÖîcE{ÅÙ_PÒãP:ˆç¿ýàǹ £‚   0‚0pUi0g0e c a¤_0]10  UUS10U
Equifax1-0+U$Equifax Secure Certificate Authority1
0UCRL10U020180822164151Z0U0U#0€Hæhù+Ò²•×GØ# O3˜ŸÔ0UHæhù+Ò²•×GØ# O3˜ŸÔ0U0ÿ0     *†H†ö}A 
0V3.0cÀ0
    *†H†÷
  XÎ)êü÷޵ιµ…ѹãà•Ì%1
 ¦’n¶’cžP•ÑšoäÞc…n˜î¨ÿZÈÓU²fqWÞÀ!ë=*§#I†B{üî¢RµggÓ@Û;&X²(w=®waÖú*f' 
ú§s\êpñ”!eD_úüï)h©¢‡yïyïO¬w8
-----END CERTIFICATE-----
]])
      conn:send("HEAD / HTTP/1.1\r\n".. 
             "Host: google.com\r\n"..
             "Accept: */*\r\n"..
             "User-Agent: Mozilla/4.0 (compatible; esp8266 Lua;)"..
             "\r\n\r\n") 
end )
conn:connect(443,"google.com")

I have to connect with HOST or REST API with HTTPS Secure connection with certificate after successful connection perform POST,GET,PUT and Delte, etc... Any one can help me to create HTTPS secure connection with HOST using Certicate.

1

1 Answers

0
votes

I have no clue what the purpose of your net.cert.verify call is and where that certificate comes from. Looks to me as if your simply trying to send a HEAD request to https://google.com. If that assumption is correct then I suggest you use the NodeMCU HTTP module which is available in NodeMCU 1.5.1.

local headers = "Accept: */*\r\n"..
                "User-Agent: Mozilla/4.0 (compatible; esp8266 Lua;)"
http.request("https://google.com", "HEAD", headers, "", 
  function(code, data)
    if (code < 0) then
      print("HTTP request failed")
    else
      print(code, data)
    end
  end)

Of course you need a firmware with SSL enabled: http://nodemcu-build.com/.