2012-09-02 16:22:22 +02:00
|
|
|
--
|
|
|
|
-- Public domain
|
|
|
|
--
|
2013-03-30 13:21:40 +01:00
|
|
|
local ssl = require("ssl")
|
2012-09-02 16:22:22 +02:00
|
|
|
|
|
|
|
local pass = "foobar"
|
|
|
|
local cfg = {
|
|
|
|
protocol = "tlsv1",
|
|
|
|
mode = "client",
|
|
|
|
key = "key.pem",
|
|
|
|
}
|
|
|
|
|
|
|
|
-- Shell
|
|
|
|
print(string.format("*** Hint: password is '%s' ***", pass))
|
|
|
|
ctx, err = ssl.newcontext(cfg)
|
|
|
|
assert(ctx, err)
|
|
|
|
print("Shell: ok")
|
|
|
|
|
|
|
|
-- Text password
|
|
|
|
cfg.password = pass
|
|
|
|
ctx, err = ssl.newcontext(cfg)
|
|
|
|
assert(ctx, err)
|
|
|
|
print("Text: ok")
|
|
|
|
|
|
|
|
-- Callback
|
|
|
|
cfg.password = function() return pass end
|
|
|
|
ctx, err = ssl.newcontext(cfg)
|
|
|
|
assert(ctx, err)
|
|
|
|
print("Callback: ok")
|