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

View File

@ -29,3 +29,6 @@ Directories:
* want
Test want().
* key
Test encrypted private key.

View File

@ -1,3 +1,5 @@
#!/bin/sh
openssl req -newkey rsa:1024 -sha1 -keyout rootAkey.pem -out rootAreq.pem -nodes -config ./rootA.cnf -days 365 -batch
openssl x509 -req -in rootAreq.pem -sha1 -extfile ./rootA.cnf -extensions v3_ca -signkey rootAkey.pem -out rootA.pem -days 365

View File

@ -1,3 +1,5 @@
#!/bin/sh
openssl req -newkey rsa:1024 -sha1 -keyout rootBkey.pem -out rootBreq.pem -nodes -config ./rootB.cnf -days 365 -batch
openssl x509 -req -in rootBreq.pem -sha1 -extfile ./rootB.cnf -extensions v3_ca -signkey rootBkey.pem -out rootB.pem -days 365

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")