bunkerweb/examples/perf/test_x509_codec.lua
Théophile Diot a280059882 Squashed 'src/deps/src/lua-resty-openssl/' content from commit b23c072a4
git-subtree-dir: src/deps/src/lua-resty-openssl
git-subtree-split: b23c072a405b749ac60d21e3946cbf57a959b780
2023-06-30 15:38:47 -04:00

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