mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
git-subtree-dir: src/deps/src/lua-resty-openssl git-subtree-split: b23c072a405b749ac60d21e3946cbf57a959b780
33 lines
1 KiB
Lua
33 lines
1 KiB
Lua
local path = debug.getinfo(1, "S").source:sub(2):match("(.*/)")
|
|
package.path = path .. "/?.lua;" .. package.path
|
|
|
|
local test = require "framework".test
|
|
local pkey = require "resty.openssl.pkey"
|
|
local example_pkey = assert(pkey.new())
|
|
|
|
for _, op in ipairs({"load", "export"}) do
|
|
for _, t in ipairs({"PEM", "DER", "JWK"}) do
|
|
for _, p in ipairs({"public", "private"}) do
|
|
|
|
if op == "load" then
|
|
local txt = assert(example_pkey:tostring(p, t))
|
|
local opts = {
|
|
format = t,
|
|
}
|
|
if t ~= "JWK" then
|
|
opts.type = p == "public" and "pu" or "pr"
|
|
end
|
|
|
|
test("load " .. t .. " " .. p .. " key", function()
|
|
return pkey.new(txt, opts)
|
|
end)
|
|
|
|
else
|
|
test("export " .. t .. " " .. p .. " key", function()
|
|
return example_pkey:tostring(p, t)
|
|
end)
|
|
end
|
|
|
|
end
|
|
end
|
|
end
|