samples/key/loadkey.lua

Sat, 17 Dec 2011 10:30:58 -0800

author
Paul Aurich <paul@darkrain42.org>
date
Sat, 17 Dec 2011 10:30:58 -0800
changeset 45
5be249c0ae71
parent 0
f7d2d78eb424
permissions
-rw-r--r--

context: Add no_compression for OpenSSL 0.9.8 as well

Since OpenSSL 0.9.8 doesn't have SSL_OP_NO_COMPRESSION, this is
implemented by simplying NULLing out the SSL_CTX->comp_methods stack.

0
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1 --
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2 -- Public domain
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3 --
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4 require("ssl")
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6 local pass = "foobar"
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7 local cfg = {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8 protocol = "tlsv1",
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9 mode = "client",
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10 key = "key.pem",
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 -- Shell
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 print(string.format("*** Hint: password is '%s' ***", pass))
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 ctx, err = ssl.newcontext(cfg)
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16 assert(ctx, err)
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17 print("Shell: ok")
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
19 -- Text password
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20 cfg.password = pass
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
21 ctx, err = ssl.newcontext(cfg)
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
22 assert(ctx, err)
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
23 print("Text: ok")
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
24
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
25 -- Callback
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
26 cfg.password = function() return pass end
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
27 ctx, err = ssl.newcontext(cfg)
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
28 assert(ctx, err)
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
29 print("Callback: ok")

mercurial