mirror of
https://github.com/brunoos/luasec.git
synced 2025-07-13 06:24:22 +02:00
LuaSec 0.3
This commit is contained in:
@ -29,3 +29,6 @@ Directories:
|
||||
|
||||
* want
|
||||
Test want().
|
||||
|
||||
* key
|
||||
Test encrypted private key.
|
||||
|
@ -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
|
||||
|
@ -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
3
samples/key/genkey.sh
Normal file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
openssl genrsa -des3 -out key.pem -passout pass:foobar 2048
|
29
samples/key/loadkey.lua
Normal file
29
samples/key/loadkey.lua
Normal 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")
|
Reference in New Issue
Block a user