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
23 lines
758 B
Lua
23 lines
758 B
Lua
local path = debug.getinfo(1, "S").source:sub(2):match("(.*/)")
|
|
package.path = path .. "/?.lua;" .. package.path
|
|
|
|
local test = require "framework".test
|
|
local x509 = require "resty.openssl.x509"
|
|
local cert = assert(io.open(path .. "../../t/fixtures/Github.pem")):read("*a")
|
|
local example_x509 = assert(x509.new(cert))
|
|
|
|
for _, op in ipairs({"load", "export"}) do
|
|
for _, t in ipairs({"PEM", "DER"}) do
|
|
if op == "load" then
|
|
local txt = assert(example_x509:tostring(t))
|
|
test("load " .. t .. " x509", function()
|
|
return x509.new(txt, t)
|
|
end)
|
|
|
|
else
|
|
test("export " .. t .. " x509", function()
|
|
return example_x509:tostring(t)
|
|
end)
|
|
end
|
|
end
|
|
end
|