samples/key/loadkey.lua

Sun, 03 Jul 2011 13:13:36 -0700

author
Paul Aurich <paul@darkrain42.org>
date
Sun, 03 Jul 2011 13:13:36 -0700
changeset 41
e26f1f91118a
parent 0
f7d2d78eb424
permissions
-rw-r--r--

Fix the verification function so it doesn't pass for everyone on invalid purpose errors.

Inspiration and code partially from Matthew

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

mercurial