File: loadkey.lua

package info (click to toggle)
lua-sec 1.3.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 740 kB
  • sloc: ansic: 3,807; makefile: 108; sh: 63
file content (29 lines) | stat: -rw-r--r-- 516 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
--
-- Public domain
--
local ssl = 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")