bunkerweb/examples/perf/test_x509_codec.lua
Théophile Diot dda63ddcee Squashed 'src/deps/src/lua-resty-openssl/' changes from 5aba923e7..7f25f00ba
7f25f00ba release: 1.2.0
40fdbbbdd feat(mac) add reset API
b36ccba3f feat(openssl) list functions can now optionally drop provider name
5381f10c3 chore(tests) bump openssl to 3.2.0 (#140)
b72870ce1 chore(perf) calculate openssl speed numbers
d23b34ae8 fix(compat) works better with plain luajit
e9edc76cb tests(perf) add kdf
dac54bf76 perf(kdf) use table.nkeys for params
3d0a51cca feat(cipher) add set_buffer_size API
ba5de3e53 perf(cipher) improve performance on cipher
e87e93f66 tests(perf) pretty up tests
c8745f9ba chore(tests) format tests
073c943bf feat(bn) add from_mpi, to_mpi and set API
253d11c54 release: 1.1.0
2e401b335 feat(pkey) support pass in ctrl str options
12f5209ff chore(tests) revert BoringSSL specific patterns
d155657e6 feat(err) standardize error format and add new API to get reason and library name
3c0027d0b doc(readme) remove docs about BoringSSL

git-subtree-dir: src/deps/src/lua-resty-openssl
git-subtree-split: 7f25f00ba2b2140b794c94b5ae17f5a0736e3b03
2023-12-29 12:36:57 +00:00

26 lines
841 B
Lua

local path = debug.getinfo(1, "S").source:sub(2):match("(.*/)")
package.path = path .. "/?.lua;" .. package.path
local test = require "framework".test
local write_seperator = require "framework".write_seperator
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 _, t in ipairs({"PEM", "DER"}) do
for _, op in ipairs({"load", "export"}) 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
write_seperator()
end