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)
@bzed
Copy link
Author

bzed commented Feb 16, 2025

For folks finding this many years later, here is a working example

nice, thank you very much! Can't even remember which haproxy version we used back then :)

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