Skip to content

Instantly share code, notes, and snippets.

@bzed
Created January 9, 2019 12:15
Show Gist options
  • Save bzed/e1e6c76e98225f997062c57aacecd2fd to your computer and use it in GitHub Desktop.
Save bzed/e1e6c76e98225f997062c57aacecd2fd to your computer and use it in GitHub Desktop.
haproxy pem formatted ssl client cert fetch - ssl_c_pem - like ssl_c_der
require("base64")
core.register_fetches("ssl_c_pem", function(txn)
local der = txn.f:ssl_c_der()
local wrap = ('.'):rep(64);
local envelope = "-----BEGIN %s-----\n%s\n-----END %s-----\n"
local typ = "CERTIFICATE";
der = base64.encode(data);
return string.format(envelope, typ, der:gsub(wrap, '%0\n', (#der-1)/64), typ);
end)
@gkatev
Copy link

gkatev commented Sep 22, 2021

Where does the 'data' variable on line 9 get defined?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment