LuaSec 0.3

This commit is contained in:
Bruno Silvestre
2012-09-02 11:22:22 -03:00
parent 36e94ee40d
commit 1c95a077ee
18 changed files with 324 additions and 126 deletions

3
samples/key/genkey.sh Normal file
View File

@ -0,0 +1,3 @@
#!/bin/sh
openssl genrsa -des3 -out key.pem -passout pass:foobar 2048

29
samples/key/loadkey.lua Normal file
View File

@ -0,0 +1,29 @@
--
-- Public domain
--
require("ssl")
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")