10.02.2020, 07:53
(10.02.2020, 06:40)admin Wrote: You are using outdated firmware where SSLv3 is used by default. It is disabled on most servers and you have to use TLSv1.2 or newer. Try using this function to make HTTPS GET request:
Code:function request(url)
local resp = {}
local stat, code, hdrs = require('ssl.https').request({
method = 'GET',
url = url,
protocol = 'tlsv12',
sink = ltn12.sink.table(resp),
})
if stat then
stat = table.concat(resp)
end
return stat, code, hdrs
end
At the moment I cannot upgrade because of a third party library...
I tried the following, but got the same error:
Code:
function request(url)
local resp = {}
local stat, code, hdrs = require('ssl.https').request({
method = 'GET',
url = url,
protocol = 'tlsv12',
sink = ltn12.sink.table(resp),
})
if stat then
stat = table.concat(resp)
end
return stat, code, hdrs
end
local telegram_url = 'https://api.telegram.org/mybot/sendMessage?'
local chat_id = '123456789'
message = "test"
data_str = 'chat_id=' .. chat_id .. '&text=' .. message..''
stat, code, hdrs = request(telegram_url, data_str)
log("code: " ..tostring(code))
log("headers: " ..tostring(hdrs))
log("status: " ..tostring(stat))