@cmkarlsson
Thank you for the answer.
The issue here is that the above certificate is not a pem file but cer file. This is what I get after I pem decode it.
[
{:Certificate,
<<48, 130, 6, 128, 48, 130, 5, 104, 160, 3, 2, 1, 2, 2, 10, 50, 250, 238,
148, 0, 0, 0, 4, 70, 228, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1,
11, 5, 0, 48, 91, 49, 19, 48, 17, 6, ...>>, :not_encrypted}
]
Here is my full implementation.
def security do
cert_text = File.read!("./lib/mpesa_elixir/keys/sandbox_cert.cer")
plain_text = " Safaricom133!"
[pem_entry] = :public_key.pem_decode(cert_text)
plk = :public_key.pem_entry_decode(pem_entry)
ciphertext = :public_key.encrypt_public(plain_text, plk, [{:rsa_pad, :rsa_pkcs1_padding}])
:base64.encode(ciphertext)
end
Here is the error am getting.
It is not my choice am trying to write an Elixir API wrapper for MPesa (Safaricom Mobile Money Transfer Service)(M-Pesa - Wikipedia).



















