我正在尝试使用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" }