2019-02-25 22:52:53 +01:00
|
|
|
--
|
|
|
|
-- Public domain
|
|
|
|
--
|
|
|
|
local socket = require("socket")
|
|
|
|
local ssl = require("ssl")
|
|
|
|
|
|
|
|
local params = {
|
2019-02-26 19:52:02 +01:00
|
|
|
mode = "server",
|
|
|
|
protocol = "any",
|
|
|
|
certificates = {
|
|
|
|
-- Comment line below and 'client-rsa' stop working
|
|
|
|
{ certificate = "certs/serverRSA.pem", key = "certs/serverRSAkey.pem" },
|
|
|
|
-- Comment line below and 'client-ecdsa' stop working
|
|
|
|
{ certificate = "certs/serverECDSA.pem", key = "certs/serverECDSAkey.pem" }
|
2019-02-25 22:52:53 +01:00
|
|
|
},
|
2019-02-26 19:52:02 +01:00
|
|
|
verify = "none",
|
|
|
|
options = "all"
|
2019-02-25 22:52:53 +01:00
|
|
|
}
|
|
|
|
|
2019-02-26 19:52:02 +01:00
|
|
|
|
|
|
|
-- [[ SSL context
|
2019-02-25 22:52:53 +01:00
|
|
|
local ctx = assert(ssl.newcontext(params))
|
2019-02-26 19:52:02 +01:00
|
|
|
--]]
|
2019-02-25 22:52:53 +01:00
|
|
|
|
|
|
|
local server = socket.tcp()
|
|
|
|
server:setoption('reuseaddr', true)
|
|
|
|
assert( server:bind("127.0.0.1", 8888) )
|
|
|
|
server:listen()
|
|
|
|
|
|
|
|
local peer = server:accept()
|
|
|
|
|
2019-02-26 19:52:02 +01:00
|
|
|
-- [[ SSL wrapper
|
2019-02-25 22:52:53 +01:00
|
|
|
peer = assert( ssl.wrap(peer, ctx) )
|
|
|
|
assert( peer:dohandshake() )
|
2019-02-26 19:52:02 +01:00
|
|
|
--]]
|
2019-02-25 22:52:53 +01:00
|
|
|
|
2019-02-26 19:52:02 +01:00
|
|
|
peer:send("oneshot test\n")
|
2019-02-25 22:52:53 +01:00
|
|
|
peer:close()
|