I’m quite new in Elixir and I’m trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and I need to convert it to
With that approach, I’d also need to add the line breaks every 64th characters in the certificate and honestly, I’m a bit confused on the string iterations for the beginning.
Somehow |> Enum.chunk(64) trimmed some characters at the end of the string and I used Enum.chunk_every() to get the string properly sliced. But apparently no need to add line breaks every 64 characters, adding only header and footer is enough for :public_key.pem_decodeto read the certificate
If the input string is a base64 encoded certificate, there is no need to add the PEM headers just so the PEM parser can strip them off again. Just use Base.decode64!/1 to get the binary (DER) certificate.