加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

https请求在lua

发布时间:2020-12-15 00:27:20 所属栏目:大数据 来源:网络整理
导读:我正在尝试使用lua脚本在启用SSL的服务器上检索一个页面.重要的是要注意,服务器具有自签名证书.由受信任的CA颁发的证书没有问题. local https = require("socket.http")local resp = {}local r,c,h,s = https.request{ url = "https://my-server:443/example
我正在尝试使用lua脚本在启用SSL的服务器上检索一个页面.重要的是要注意,服务器具有自签名证书.由受信任的CA颁发的证书没有问题.
local https = require("socket.http")
local resp = {}
local r,c,h,s = https.request{
    url = "https://my-server:443/example.php",sink = ltn12.sink.table(resp),protocol = "tlsv1"
}

服务器返回:

Bad Request
Your browser sent a request that this server could not understand.
Reason: You’re speaking plain HTTP to an SSL-enabled server port.
Instead use the HTTPS scheme to access this URL,please.

而在服务器端,该请求在Apache ssl_access.log中产生此条目

192.168.0.150 - - [27/Nov/2011:16:32:07 +0100] "GET /" 400 529 "-" "-"

此外,tcpdump显示在SYN-ACK握手后,不发送SSL 257 Client Hello.从我的浏览器或wget使用相同的URL可以正常工作.

解决方法

正如Doug Currie所说,你应该使用 luasec.为了启用https.request,你必须要求ssl.https模块:
local https = require 'ssl.https'
local r,protocol = "tlsv1"
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读