如何用Lua实现HTTPS请求?

2026-04-01 19:551阅读0评论SEO教程
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计252个文字,预计阅读时间需要2分钟。

如何用Lua实现HTTPS请求?

我正在尝试在启用SSL的服务器上使用Lua脚本搜索一个页面。需要注意的是,服务器必须具有自签名证书。由受信任的CA签发的证书没有问题。代码如下:

lualocal https=require(socket.http)local resp={}

local r, c, h=https.request(https://example.com, nil, {ssl_verify_mode=none})print(r)

我正在尝试使用lua脚本在启用SSL的服务器上检索一个页面.重要的是要注意,服务器具有自签名证书.由受信任的CA颁发的证书没有问题.

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

如何用Lua实现HTTPS请求?

而在服务器端,该请求在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.为了启用my-server:443/example.php", sink = ltn12.sink.table(resp), protocol = "tlsv1" }

本文共计252个文字,预计阅读时间需要2分钟。

如何用Lua实现HTTPS请求?

我正在尝试在启用SSL的服务器上使用Lua脚本搜索一个页面。需要注意的是,服务器必须具有自签名证书。由受信任的CA签发的证书没有问题。代码如下:

lualocal https=require(socket.http)local resp={}

local r, c, h=https.request(https://example.com, nil, {ssl_verify_mode=none})print(r)

我正在尝试使用lua脚本在启用SSL的服务器上检索一个页面.重要的是要注意,服务器具有自签名证书.由受信任的CA颁发的证书没有问题.

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

如何用Lua实现HTTPS请求?

而在服务器端,该请求在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.为了启用my-server:443/example.php", sink = ltn12.sink.table(resp), protocol = "tlsv1" }