public_key:pem_decode/1 and public_key:verify/4

Joakim G. <>
Wed Jan 19 10:23:56 CET 2011


Hi all,
It seems that public_key:pem_decode/1 can't decode public
keys.

I wanted use public_key:verify/4 to verify a digital signature
and for that I used public_key:pem_decode/1 to extract the
public key.

26> {ok, Bin} = file:read_file("key.pub").
{ok,<<"-----BEGIN RSA PUBLIC
KEY-----\nMIGJAoGBAKhhZ8RrKaA0RWhjXJlSpTHd7/h6Luww9qeyUkEqBQyiCooZZGCYNle5C9TfRVJDUuxz"...>>}
27> rp(Bin).
<<"-----BEGIN RSA PUBLIC
KEY-----\nMIGJAoGBAKhhZ8RrKaA0RWhjXJlSpTHd7/h6Luww9qeyUkEqBQyiCooZZGCYNle5\nC9TfRVJDUuxzigvXuTh0tlba+9AyIe2hxAztjs43pSKy5VnnJlSjMBVDay8XmNjh\nlUxid/ZV2hDkKlwHDCnZjdZpeXqdtGbZ7o3N7wOBzJSRQ7kqzQHXAgMBAAE=\n-----END
RSA PUBLIC KEY-----\n">>
ok
28> public_key:pem_decode(Bin).
[]

That was a surprise.

Cheers
/Jocke


More information about the erlang-questions mailing list